Specifying sheets in a different workbook

Matt

Board Regular
Joined
Feb 16, 2002
Messages
212
I have this code to specify the lastrow, can someone help me with the code to specify a sheet in a different workbook.

lastrow = Sheets("Complete").Cells(Rows.Count, "B").End(xlUp).Row

thanks

Matt
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
On 2002-04-17 08:23, Matt wrote:
I have this code to specify the lastrow, can someone help me with the code to specify a sheet in a different workbook.

lastrow = Sheets("Complete").Cells(Rows.Count, "B").End(xlUp).Row

thanks

Matt

Hi Matt,

Qualify it with the Workbooks reference. You may need to specify the path, but if the other workbook is open, the following should work.

lastrow = Workbooks("My file.xls").Sheets("Complete").Cells(Rows.Count, "B").End(xlUp).Row

The original reference can be made more complete by using ThisWorkbook.

lastrow = ThisWorkbook.Sheets("Complete").Cells(Rows.Count, "B").End(xlUp).Row

although that is not a requirement.

Bye,
Jay
 
Upvote 0

Forum statistics

Threads
1,214,411
Messages
6,119,356
Members
448,888
Latest member
Arle8907

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