VBA Quirk?

normpam

Active Member
Joined
Oct 30, 2002
Messages
355
My code works perfectly on numerous sheets, but on four or five out of maybe 18, it stops and displays an error. Here's the strange thing. Each of the sheets are in the 'page break' view. If I change the view to 'normal' on any of non-working sheets, the code runs just fine! In addition, if I use the 'step mode', I also get no error.

Any ideas? Thanks!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
You might get some useful responses if you posted the code your are using.. :) :)
AND
What error msg are you getting
 
Upvote 0
You might get some useful responses if you posted the code your are using.. :) :)
AND
What error msg are you getting
run-time error '450'
Wrong number of arguments or invalid property assignment

The code that is highlighted is: Range("Size").Offset(1, 0).Name = "Size", which works just fine in most of the sheets, and if run in step mode.
 
Upvote 0
I kinda meant...ALL of the code .. :)
Are you trying to increase the range of "Size" ?
 
Upvote 0
I kinda meant...ALL of the code .. :)
Are you trying to increase the range of "Size" ?
The complete code is hundreds of lines.... what is so strange is that this simple line of code is just renaming a range; it works perfectly on numerous sheets; runs just fine in step mode on other sheets, but on some of those other sheets, will not run if in 'page break' view, and, if I just simply change the view to 'norman', it works!
 
Upvote 0
Does the "Size" range creep over into the naxt page ( in Page Break view)
Also, what is the actual range of "Size" ie, A1:D20, etc ?
 
Upvote 0
Does the "Size" range creep over into the naxt page ( in Page Break view)
Also, what is the actual range of "Size" ie, A1:D20, etc ?
Good idea... but in fact, the range is initially cell A4, and simply gets renamed for cell A5, so the page view shouldn't matter at all. Plus, again, the code runs perfectly if done in step mode.
 
Upvote 0
your line of code works for me with Activesheet added
Are you activating each worksheet, or Using a With..end with statement
VBA Code:
ActiveSheet.Range("Size").Offset(1, 0).Name = "Size"
If the latter, I'd suggest
VBA Code:
dim ws as worksheet
for each worksheet in worksheets
With ws
.Range("Size").Offset(1, 0).Name = "Size"
end with
next ws
 
Upvote 0
your line of code works for me with Activesheet added
Are you activating each worksheet, or Using a With..end with statement
VBA Code:
ActiveSheet.Range("Size").Offset(1, 0).Name = "Size"
If the latter, I'd suggest
VBA Code:
dim ws as worksheet
for each worksheet in worksheets
With ws
.Range("Size").Offset(1, 0).Name = "Size"
end with
next ws
Nope. not using an activation code. Was just wondering what kind of quirk could cause a VBA script to work in 'normal' view, but not in a 'page preview' view, and then again, works perfectly well on other sheets EVEN BEING IN PAGE PREVIEW VIEW' and then again, works just fine in step mode no matter what the view.
 
Upvote 0
No cell protection on the "naughty" sheets ??
Have you tried it on a Dummy workbook to see what happens......worked fine for me in any view !!
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

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