VBA and Macros for Microsoft Excel

Shinano

Board Regular
Joined
Dec 5, 2004
Messages
65
Office Version
  1. 365
Platform
  1. Windows
I have started to read this book from page 1. Yes, I am still a VBA beginner...

Anyway, my curiousity got caught by the comment under CAUTION on page 55.

If this code:

Cells(Row.Count,1).End(xlUp)

Can be combined with this code:

FinalRow = Range("A65536").End(xlUP).Row

To enable compatibility with older versions of Excel, which does not have that many rows, then how is this done?

Any explanation is appreciated.

T.i.a.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Using this statement
Code:
Rows.Count
in excel 2007 it will count 1,048,576 rows and in other version 65536 rows

So use this to be dynamic in both versions
Code:
FinalRow = Cells(Rows.Count,1).End(xlUp).Row
and this when not working in 2007 or not exceeding 65536 rows
Code:
FinalRow = Range("A65536").End(xlUP).Row
VBA Noob
 
Last edited by a moderator:
Thanks a lot for the explanation. I appreciate it.
 

Forum statistics

Threads
1,222,713
Messages
6,167,813
Members
452,141
Latest member
CaseyJones1979

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