Application-defined or object-defined error -excel VBA

Mahmoud Sayed

New Member
Joined
Sep 29, 2021
Messages
19
Office Version
  1. 2010
Platform
  1. Windows
Private Sub commandButton1_click()
Dim last As integer
Last = sheet2.Range(B"1000").End(x1Up).Row + 1
Sheet2.Cells(last, "B").value = Me.TextBox1.value
sheet2.cells(last, "C").value = Me.textbox2.value
Sheet2.Cells(last, "D").value = Me.TextBox3.value
Sheet2.Cells(last, "E").value = Me.TextBox4.value
Sheet2.Cells(last, "F").value = Me.TextBox5.value
Sheet2.Cells(last, "G").value = Me.TextBox6.value
Sheet2.Cells(last, "H").value = Me.TextBox7.value
Sheet2.Cells(last, "I").value =
Me.TextBox8.value
Me.TextBox1.value = ""
Me.TextBox2.value = ""
Me.TextBox3.value = ""
Me.TextBox4.value = ""
Me.TextBox5.value = ""
Me.TextBox6.value = ""
Me.TextBox7.value = ""
Me.TextBox8.value = ""
Msgbox "Saved Successfuly", vbInformation
listsource

End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
VBA Code:
Private Sub commandButton1_click()
Dim last As Integer
last = sheet2.Range("B1000").End(xlUp).Row + 1    'wrong string for range, 1 instaed of small L
sheet2.Cells(last, "B").Value = Me.TextBox1.Value
sheet2.Cells(last, "C").Value = Me.TextBox2.Value
sheet2.Cells(last, "D").Value = Me.TextBox3.Value
sheet2.Cells(last, "E").Value = Me.TextBox4.Value
sheet2.Cells(last, "F").Value = Me.TextBox5.Value
sheet2.Cells(last, "G").Value = Me.TextBox6.Value
sheet2.Cells(last, "H").Value = Me.TextBox7.Value
sheet2.Cells(last, "I").Value = Me.TextBox8.Value  'should be on one line
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
MsgBox "Saved Successfuly", vbInformation
listsource

End Sub
 
Upvote 0
VBA Code:
Private Sub commandButton1_click()
Dim last As Integer
last = sheet2.Range("B1000").End(xlUp).Row + 1    'wrong string for range, 1 instaed of small L
sheet2.Cells(last, "B").Value = Me.TextBox1.Value
sheet2.Cells(last, "C").Value = Me.TextBox2.Value
sheet2.Cells(last, "D").Value = Me.TextBox3.Value
sheet2.Cells(last, "E").Value = Me.TextBox4.Value
sheet2.Cells(last, "F").Value = Me.TextBox5.Value
sheet2.Cells(last, "G").Value = Me.TextBox6.Value
sheet2.Cells(last, "H").Value = Me.TextBox7.Value
sheet2.Cells(last, "I").Value = Me.TextBox8.Value  'should be on one line
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
MsgBox "Saved Successfuly", vbInformation
listsource

End Sub
How on one line ?
Appear a new error
 
Upvote 0
What error did you get & what line is highlighted when you click debug?
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Run-time error '1004': Application-defined or object-defined error -excel VBA
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
It's XLUP not X1UP (it's an L not the number one)
 
Upvote 0
Solution
That is not the code posted by HaHoBe it should be a lower case L not a 1 in xlUp
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,656
Members
449,045
Latest member
Marcus05

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