i need quick help plz.

realman07

New Member
Joined
Sep 29, 2011
Messages
23
i have made a project by excel with VB programming under excel 2003
now:
how can i let this project work under excel 2007 or higher version???
i found different in number of columns and rows between versions of excel .... did all that i need to update program to calculate new number of columns and rows only,,,example:

in excel 2003 to find last column: code is
cc = Sheet2.Columns(256).End(xlToLeft).Column
also to find last row: code is
lastrow = Sheet1.Rows(65536).End(xlUp).Row

all that codes likely must be changed ,,,, so what else????

thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi,

I think instead of hard coding the number of rows/columns it would be better to say:

cc = Sheet2.Columns(Columns.Count).End(xlToLeft).Column
lastrow = Sheet1.Rows(Rows.Count).End(xlUp).Row
 
Upvote 0
realman07,


The following should work for all versions of Excel.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Rich (BB code):
Dim cc As Long, lastrow As Long

'in excel 2003 to find last column: code is
'cc = Sheet2.Columns(256).End(xlToLeft).Column
cc = Worksheets("Sheet2").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

'also to find last row: code is
'lastrow = Sheet1.Rows(65536).End(xlUp).Row
lastrow = Worksheets("Sheet1").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
 
Last edited:
Upvote 0
thanks alot
i'll try that
but is ther some thing else that i must be changed if i need to operate this project under 2007 or higher versions?????

thanks
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,792
Members
452,942
Latest member
VijayNewtoExcel

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