VBA ERROR IN READING THE SHEET

blackorchids2002

Board Regular
Joined
Dec 29, 2011
Messages
135
Hello Masters,

I am having an error bellow when using a command button.

My starting point is in Sheet 2. I want to get the last row that has a record in Sheet 1 but it continue to read the last row in Sheet 2.

Sheet 1 is my raw data
Sheet 2 is my report and has list on it.


Private Sub CommandButton1_Click()

Dim Last_Row As Long
Dim mmraw As Worksheet

Set mmraw = Sheets("Excel Report")
mmraw.Select
mmraw.Cells(1, 1).Select
Set mmraw = ActiveSheet
With ActiveSheet
Last_Row = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox Last_Row
End With
End Sub

Thanks :)
 

Some videos you may like

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

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,953
Office Version
  1. 365
Platform
  1. Windows
What is the name of Sheet1?
 

Dossfm0q

Banned User
Joined
Mar 9, 2009
Messages
570
Office Version
  1. 2019
Platform
  1. Windows
Hi

Last_Row = Name Off Sheet as Fluff recommend .Cells(Rows.Count, 1).End(xlUp).Row
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,953
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,556
Messages
5,596,820
Members
414,104
Latest member
imamalidadashzada

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