How to Make the Data from my UserForm Go into another page

vdailey2016

New Member
Joined
Sep 10, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
My code is posted below. I want to take it from the "Log Form" Sheet to the "Cage Inventory" Sheet

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub CommandButton2_Click()
If Range("b2") <> "" Then
Rows("2:2").Select
Selection.Insert shift:=x1down
End If

If Range("b2") = "" Then
sheetsRange("b2") = TextBox1.Text
Range("C2") = TextBox2.Text
Range("D2") = TextBox3.Text
Range("E2") = TextBox4.Text
Range("F2") = TextBox5.Text
Range("G2") = TextBox6.Text
Range("H2") = TextBox7.Text
Range("I2") = TextBox8.Text
Range("J2") = TextBox9.Text
Range("L2") = TextBox10.Text
Range("N2") = TextBox11.Text
Range("O2") = TextBox12.Text

End If

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""

Range("Q1").Select



MsgBox "Material Has Been Checked In Successfully"

End Sub

Private Sub Label8_Click()

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Code:
Private Sub CommandButton2_Click()
with sheets("Cage Inventory")
If .Range("b2") <> "" Then
.Rows("2:2").insert shift:=x1down
End If

If .Range("b2") = "" Then
.Range("b2") = TextBox1.Text
.Range("C2") = TextBox2.Text
.Range("D2") = TextBox3.Text
.Range("E2") = TextBox4.Text
.Range("F2") = TextBox5.Text
.Range("G2") = TextBox6.Text
.Range("H2") = TextBox7.Text
.Range("I2") = TextBox8.Text
.Range("J2") = TextBox9.Text
.Range("L2") = TextBox10.Text
.Range("N2") = TextBox11.Text
.Range("O2") = TextBox12.Text

End If
end with
 
Upvote 0
Thank you!

And is there anyway that I can delete this
If Range("b2") <> "" Then
Rows("2:2").Select
Selection.Insert shift:=x1down
End If

And make it so that it goes from row 2 and down? So that the first entry will be in row 2 and the next entry will be in row 3?

Code:
[QUOTE="davesexcel, post: 5553633, member: 58374"]
[code]
Private Sub CommandButton2_Click()
with sheets("Cage Inventory")
If .Range("b2") <> "" Then
.Rows("2:2").insert shift:=x1down
End If

If .Range("b2") = "" Then
.Range("b2") = TextBox1.Text
.Range("C2") = TextBox2.Text
.Range("D2") = TextBox3.Text
.Range("E2") = TextBox4.Text
.Range("F2") = TextBox5.Text
.Range("G2") = TextBox6.Text
.Range("H2") = TextBox7.Text
.Range("I2") = TextBox8.Text
.Range("J2") = TextBox9.Text
.Range("L2") = TextBox10.Text
.Range("N2") = TextBox11.Text
.Range("O2") = TextBox12.Text

End If
end with

Private Sub CommandButton2_Click()
with sheets("Cage Inventory")
If .Range("b2") <> "" Then
.Rows("2:2").insert shift:=x1down
End If

If .Range("b2") = "" Then
.Range("b2") = TextBox1.Text
.Range("C2") = TextBox2.Text
.Range("D2") = TextBox3.Text
.Range("E2") = TextBox4.Text
.Range("F2") = TextBox5.Text
.Range("G2") = TextBox6.Text
.Range("H2") = TextBox7.Text
.Range("I2") = TextBox8.Text
.Range("J2") = TextBox9.Text
.Range("L2") = TextBox10.Text
.Range("N2") = TextBox11.Text
.Range("O2") = TextBox12.Text

End If
end with
[/code]
[/QUOTE]
Code:
Private Sub CommandButton2_Click()
with sheets("Cage Inventory")
If .Range("b2") <> "" Then
.Rows("2:2").insert shift:=x1down
End If

If .Range("b2") = "" Then
.Range("b2") = TextBox1.Text
.Range("C2") = TextBox2.Text
.Range("D2") = TextBox3.Text
.Range("E2") = TextBox4.Text
.Range("F2") = TextBox5.Text
.Range("G2") = TextBox6.Text
.Range("H2") = TextBox7.Text
.Range("I2") = TextBox8.Text
.Range("J2") = TextBox9.Text
.Range("L2") = TextBox10.Text
.Range("N2") = TextBox11.Text
.Range("O2") = TextBox12.Text

End If
end with

Code:
Private Sub CommandButton2_Click()
with sheets("Cage Inventory")
If .Range("b2") <> "" Then
.Rows("2:2").insert shift:=x1down
End If

If .Range("b2") = "" Then
.Range("b2") = TextBox1.Text
.Range("C2") = TextBox2.Text
.Range("D2") = TextBox3.Text
.Range("E2") = TextBox4.Text
.Range("F2") = TextBox5.Text
.Range("G2") = TextBox6.Text
.Range("H2") = TextBox7.Text
.Range("I2") = TextBox8.Text
.Range("J2") = TextBox9.Text
.Range("L2") = TextBox10.Text
.Range("N2") = TextBox11.Text
.Range("O2") = TextBox12.Text

End If
end with
 
Upvote 0
This will -place the data in the next available row.

VBA Code:
Dim LstRw           As Long

With Sheets("Cage Inventory")
    LstRw = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
    'If .Range("b2") <> "" Then
    '.Rows("2:2").Insert shift:=x1down
    'End If
    
    If .Range("b" & LstRw) = "" Then
        .Range("b" & LstRw) = TextBox1.Text
        .Range("C" & LstRw) = TextBox2.Text
        .Range("D" & LstRw) = TextBox3.Text
        .Range("E" & LstRw) = TextBox4.Text
        .Range("F" & LstRw) = TextBox5.Text
        .Range("G" & LstRw) = TextBox6.Text
        .Range("H" & LstRw) = TextBox7.Text
        .Range("I" & LstRw) = TextBox8.Text
        .Range("J" & LstRw) = TextBox9.Text
        .Range("L" & LstRw) = TextBox10.Text
        .Range("N" & LstRw) = TextBox11.Text
        .Range("O" & LstRw) = TextBox12.Text
        
    End If
End With
 
Upvote 0

Forum statistics

Threads
1,215,464
Messages
6,124,967
Members
449,200
Latest member
Jamil ahmed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top