Differences between VBA in 2003 vs 2007

Melpp

New Member
Joined
May 3, 2011
Messages
29
I had a working code in Excel 2003 but it does not seem to run in Excel 2007. The first error that comes up is related to the following line:
Last_Row = ActiveSheet.UsedRange.Rows.Count

Please Help
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
None of the references are missing.

It seems that if I define the varaibles at the begining of the code (such as: ' Dim Max').

But I am now getting an error on the following line:
If Cells(j, 13 + 3 * z) <> blank Then

Recall that this code runs perfectly in the 2003 version so why am I having so many problems in the 2007 version.
 
Upvote 0
Blank is a declared variable?

It sounds like you now have Option Explicit at the top of the module, requiring you to define variables, and previously did not.
 
Upvote 0
How do I change this option?

Under VBA--> Tools--> Options, the 'require Variable Declaration' is NOT checkmarked so why am I still having this problem?
 
Last edited:
Upvote 0
It should be checked, and you should declare your variables. But you didn't answer my question ...
 
Upvote 0
Blank is not a delcared variable....or atleast I never had to declare it in Excel 2003. I used blank to indicate that there is no content in a cell
 
Upvote 0
When you don't require variable declaration and just stick in a new variable name, a Variant variable is created, and its initial value is Empty, which is the same as an empty cell. So your code works serendipitously, not by design.

If you want to test if a cell is Empty, use IsEmpty(cell.value).
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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