ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with vba user form (https://www.excelbanter.com/excel-programming/309363-help-vba-user-form.html)

Dave W[_3_]

help with vba user form
 
I am learning how to add a user form
I'm following a knowledge base article # 213749

I've set up the user form
every thing seems to be right except
I'm getting an compile error message at

Set LastRow = Sheet1.Range("A65536").End(x1Up)

Here is the code from the instructions:

Private Sub CommandButton1_Click()

Dim LastRow As Object

Set LastRow = Sheet1.Range("A65536").End(x1Up)

LastRow.Offset(1, 0).Value = TextBox1.Text
LastRow.Offset(1, 1).Value = TextBox2.Text
LastRow.Offset(1, 2).Value = TextBox3.Text

MsgBox "One record written to sheet 1"

response = MsgBox("Do you want to enter another
record?", vbYesNo)

If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox.Text = ""

TextBox1.SetFocus

Else
Unload Me
End If


End Sub

Private Sub CommandButton2_CLick()
End

End Sub
Can anyone tell me what's wrong
Is there a mistake in the code or am I doing something
wrong?

JulieD

help with vba user form
 
Hi Dave

it's XLUP
not X1UP

the letter L not the number 1

Cheers
JulieD

"Dave W" wrote in message
...
I am learning how to add a user form
I'm following a knowledge base article # 213749

I've set up the user form
every thing seems to be right except
I'm getting an compile error message at

Set LastRow = Sheet1.Range("A65536").End(x1Up)

Here is the code from the instructions:

Private Sub CommandButton1_Click()

Dim LastRow As Object

Set LastRow = Sheet1.Range("A65536").End(x1Up)

LastRow.Offset(1, 0).Value = TextBox1.Text
LastRow.Offset(1, 1).Value = TextBox2.Text
LastRow.Offset(1, 2).Value = TextBox3.Text

MsgBox "One record written to sheet 1"

response = MsgBox("Do you want to enter another
record?", vbYesNo)

If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox.Text = ""

TextBox1.SetFocus

Else
Unload Me
End If


End Sub

Private Sub CommandButton2_CLick()
End

End Sub
Can anyone tell me what's wrong
Is there a mistake in the code or am I doing something
wrong?




JulieD

help with vba user form
 
you're welcome and thanks for the feedback

wrote in message
...
Thank you


-----Original Message-----
Hi Dave

it's XLUP
not X1UP

the letter L not the number 1

Cheers
JulieD

"Dave W" wrote in

message
...
I am learning how to add a user form
I'm following a knowledge base article # 213749

I've set up the user form
every thing seems to be right except
I'm getting an compile error message at

Set LastRow = Sheet1.Range("A65536").End(x1Up)

Here is the code from the instructions:

Private Sub CommandButton1_Click()

Dim LastRow As Object

Set LastRow = Sheet1.Range("A65536").End(x1Up)

LastRow.Offset(1, 0).Value = TextBox1.Text
LastRow.Offset(1, 1).Value = TextBox2.Text
LastRow.Offset(1, 2).Value = TextBox3.Text

MsgBox "One record written to sheet 1"

response = MsgBox("Do you want to enter another
record?", vbYesNo)

If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox.Text = ""

TextBox1.SetFocus

Else
Unload Me
End If


End Sub

Private Sub CommandButton2_CLick()
End

End Sub
Can anyone tell me what's wrong
Is there a mistake in the code or am I doing something
wrong?



.




No Name

help with vba user form
 
Thank you


-----Original Message-----
Hi Dave

it's XLUP
not X1UP

the letter L not the number 1

Cheers
JulieD

"Dave W" wrote in

message
...
I am learning how to add a user form
I'm following a knowledge base article # 213749

I've set up the user form
every thing seems to be right except
I'm getting an compile error message at

Set LastRow = Sheet1.Range("A65536").End(x1Up)

Here is the code from the instructions:

Private Sub CommandButton1_Click()

Dim LastRow As Object

Set LastRow = Sheet1.Range("A65536").End(x1Up)

LastRow.Offset(1, 0).Value = TextBox1.Text
LastRow.Offset(1, 1).Value = TextBox2.Text
LastRow.Offset(1, 2).Value = TextBox3.Text

MsgBox "One record written to sheet 1"

response = MsgBox("Do you want to enter another
record?", vbYesNo)

If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox.Text = ""

TextBox1.SetFocus

Else
Unload Me
End If


End Sub

Private Sub CommandButton2_CLick()
End

End Sub
Can anyone tell me what's wrong
Is there a mistake in the code or am I doing something
wrong?



.



All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com