I am working on a userform for work and I am having some issues with data where I would like it to go. We would be using this at a station where we would be recording downtime for our operation line as it's running. Most of the time if we have any downtime, it would only be once per lot we are running. But we have the chance to run into multiple downtime situations. On the userform I would have them labeled as downtime 1, downtime 2 and downtime 3.
So I have downtime 1 star time Command button set to record to the next available column D.
Private Sub CommandButton3_Click()
Dim ws As Worksheet
Dim nextRow As Long
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Data")
' Find the next available row in column D
nextRow = ws.Cells(ws.Rows.Count, "D").End(xlUp).Row + 1
' Add current time to the next available row in column B
ws.Cells(nextRow, "D").Value = Now
' Show the date and time in TextBox5 on UserForm1
UserForm1.TextBox5.Value = Now
End Sub
Lets say that data goes to Row 1 , Column D.
Now on the next lot I might have 2 times that I would have to record downtime. Using downtime 1 command button again, it will go to Row 2, Column D.
BUT I have downtime 2 to go Column G, but if I click it, the data would be recorded in Row 1, Column G, when I need the data to be in Row 2, Column G.
How would you right the VBA to not only go to the next available Column, but go into the Row that you are using at the time.
Sorry, this might be long and wordy, but if you need more info to help...let me know.
So I have downtime 1 star time Command button set to record to the next available column D.
Private Sub CommandButton3_Click()
Dim ws As Worksheet
Dim nextRow As Long
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Data")
' Find the next available row in column D
nextRow = ws.Cells(ws.Rows.Count, "D").End(xlUp).Row + 1
' Add current time to the next available row in column B
ws.Cells(nextRow, "D").Value = Now
' Show the date and time in TextBox5 on UserForm1
UserForm1.TextBox5.Value = Now
End Sub
Lets say that data goes to Row 1 , Column D.
Now on the next lot I might have 2 times that I would have to record downtime. Using downtime 1 command button again, it will go to Row 2, Column D.
BUT I have downtime 2 to go Column G, but if I click it, the data would be recorded in Row 1, Column G, when I need the data to be in Row 2, Column G.
How would you right the VBA to not only go to the next available Column, but go into the Row that you are using at the time.
Sorry, this might be long and wordy, but if you need more info to help...let me know.