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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

HaHoBe

Active Member
Joined
Jan 24, 2003
Messages
497
Office Version
  1. 2013
Platform
  1. Windows
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
 

Mahmoud Sayed

New Member
Joined
Sep 29, 2021
Messages
19
Office Version
  1. 2010
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,949
Office Version
  1. 365
Platform
  1. Windows
What error did you get & what line is highlighted when you click debug?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,562
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

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.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,562
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
It's XLUP not X1UP (it's an L not the number one)
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,949
Office Version
  1. 365
Platform
  1. Windows
That is not the code posted by HaHoBe it should be a lower case L not a 1 in xlUp
 

Forum statistics

Threads
1,144,281
Messages
5,723,473
Members
422,499
Latest member
think say

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
Top