Excelnoub
Member
I have a UserForm with Testboxes in it and I have the code to make this work perfect. I need an addon to this code but am lost (Section of the code...where to add it and how)
In my UserForm I have a CommandButton1 that would take all information inserted and paste it to the next available row in my Worksheet.
Here is part of my UserForm CommandButton1_Click() code:
[pre]<br />
Private Sub CommandButton1_Click()<br />
Dim rNextCl As Range<br />
Dim NextRw As Long<br />
...<br />
If CheckBox1 Then<br />
AddTo = "/A"<br />
Else: AddTo = ""<br />
End If</p>
<p>With Sheet1<br />
NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1</p>
<p> .Cells(NextRw, 1).Value = Me.TextBox1.Value & AddTo<br />
.Cells(NextRw, 2).Value = Me.TextBox2.Value<br />
.Cells(NextRw, 3).Value = Me.TextBox3.Value<br />
.Cells(NextRw, 4).Value = Me.TextBox4.Value<br />
.Cells(NextRw, 11).Value = Me.TextBox5.Value<br />
.Cells(NextRw, 12).Value = Me.TextBox6.Value<br />
.Cells(NextRw, 5).Value = Me.ComboBox1.Value<br />
.Cells(NextRw, 6).Value = Me.ComboBox2.Value<br />
End With<br />
Unload Me<br />
End Sub<br />
[/pre]
If you follow part of this code, when I hit my commandbutton it will take all the information and add it to my row. If the checkbox = true then it will add a "/A" to my Textbox1 that is located in my Column A Whatever row.
I need to add to this code.
If the checkbox is selected Add a "/A" to that Textbox but also Offset the entire row that will be inserted but add a "/B" to the offseted row in my, what will be the next available row, row underneath.
So in a picture... If checkbox is selected
My example is on my Row 5 but this could also be whatever row, all depends what is my next available row in my sheet when I call my userform...
A5 = Test/A
Next row
A6 = Test/B
The code above does the /A but I need help with the /B part...
Please help
In my UserForm I have a CommandButton1 that would take all information inserted and paste it to the next available row in my Worksheet.
Here is part of my UserForm CommandButton1_Click() code:
[pre]<br />
Private Sub CommandButton1_Click()<br />
Dim rNextCl As Range<br />
Dim NextRw As Long<br />
...<br />
If CheckBox1 Then<br />
AddTo = "/A"<br />
Else: AddTo = ""<br />
End If</p>
<p>With Sheet1<br />
NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1</p>
<p> .Cells(NextRw, 1).Value = Me.TextBox1.Value & AddTo<br />
.Cells(NextRw, 2).Value = Me.TextBox2.Value<br />
.Cells(NextRw, 3).Value = Me.TextBox3.Value<br />
.Cells(NextRw, 4).Value = Me.TextBox4.Value<br />
.Cells(NextRw, 11).Value = Me.TextBox5.Value<br />
.Cells(NextRw, 12).Value = Me.TextBox6.Value<br />
.Cells(NextRw, 5).Value = Me.ComboBox1.Value<br />
.Cells(NextRw, 6).Value = Me.ComboBox2.Value<br />
End With<br />
Unload Me<br />
End Sub<br />
[/pre]
If you follow part of this code, when I hit my commandbutton it will take all the information and add it to my row. If the checkbox = true then it will add a "/A" to my Textbox1 that is located in my Column A Whatever row.
I need to add to this code.
If the checkbox is selected Add a "/A" to that Textbox but also Offset the entire row that will be inserted but add a "/B" to the offseted row in my, what will be the next available row, row underneath.
So in a picture... If checkbox is selected
My example is on my Row 5 but this could also be whatever row, all depends what is my next available row in my sheet when I call my userform...
A5 = Test/A
Next row
A6 = Test/B
The code above does the /A but I need help with the /B part...
Please help