Reputation: 69
I have three columns- Parent Job, Child Job , and Details.
Under parent jobs, I have a number of child jobs.
For each parent job in the first column, I want to insert all its child jobs in the second column, going down by one row.
Both parent jobs and child jobs have some details in the third column.
I designed a userform. I insert my data using a button for the parent job and another for the child job.
Below are screenshots of what I am trying to do. (Data manually inserted.)
For the Child Job, I am able to move to a new row.
For the Parent Job, I am unable to move to an immediate new row after the child meaning that instead of filling in data for the new parent job just below the last child job, the row below the parent job fills in whenever I click the Register parent button multiple times, as you can see from my current output.
I played with ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
in many ways.
My full VBA code:
Private Sub btn_registerChildJob_Click()
Application.DisplayAlerts = False
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1) = ""
Cells(erow, 2) = " " + TextBox2.Text
Cells(erow, 3) = "Test Data"
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub
Private Sub btnResgiterParentJob_Click()
Application.DisplayAlerts = False
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1).Font.Bold = True
Cells(erow, 1).Font.Color = vbRed
Cells(erow, 1) = TextBox1.Text
Cells(erow, 3) = "Test Data"
End Sub
Upvotes: 0
Views: 69