ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet is not updated (https://www.excelbanter.com/excel-programming/317054-worksheet-not-updated.html)

Rachael[_3_]

Worksheet is not updated
 
hello all, i'm just a beginner at excel & vB so i could use some help
here. I've this code that allows me to enter some information through
a form and it should write to a row in the sheet. Even though it says
"a record has been added!", nothing appears on the sheet. Confused by
this! Will someone help me in this? Thanks!

Private Sub CommandButton1_Click()
Dim LastRow As Object

Set LastRow = Sheet1.Range("a65536").End(xlUp)

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 Sheet1"

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

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

TextBox1.SetFocus

Else
Unload Me
End If

Dave Peterson[_5_]

Worksheet is not updated
 
I'd change this (at least for testing):

MsgBox "One record written to Sheet1"
to
MsgBox "One record written to Sheet1 to row " & lastrow.Row + 1

Any chance your data is missing stuff from column A. Maybe you're going too far
up column A.

And you're using the codename for sheet1. Are you sure that you're looking at
the correct worksheet?



Rachael wrote:

hello all, i'm just a beginner at excel & vB so i could use some help
here. I've this code that allows me to enter some information through
a form and it should write to a row in the sheet. Even though it says
"a record has been added!", nothing appears on the sheet. Confused by
this! Will someone help me in this? Thanks!

Private Sub CommandButton1_Click()
Dim LastRow As Object

Set LastRow = Sheet1.Range("a65536").End(xlUp)

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 Sheet1"

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

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

TextBox1.SetFocus

Else
Unload Me
End If


--

Dave Peterson


All times are GMT +1. The time now is 10:57 PM.

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