Macro Error on Cell.Select

dcliffo

Board Regular
Joined
Jun 18, 2003
Messages
148
The following macro works fine on my machine, but when I copy it to another co-worker's machine, I get a "Select method of range Class failed." It also worked fine on the co-worker's machine last Wednesday and now causes the above error. Help :ROFLMAO:

Sub KDollars()
Dim rngBig As Range, rngCell As Range

Set rngBig = Range("C11:AO" & Range("AO65536").End(xlUp).Row)
ActiveSheet.Unprotect

For Each rngCell In rngBig.Cells
rngCell.Value = rngCell / 1000
Next rngCell
rngBig.NumberFormat = "0.0"

With Selection.Font
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$10"
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "&8&P"
.RightFooter = "&8&D"
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = 95
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 2
End With
Cells.Select
Selection.Columns.AutoFit
Selection.RowHeight = 20
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi:

When you use the debug utility, where in the macro does it fail?



Is this a valid range? Set rngBig = Range("C11:AO" & Range("AO65536").End(xlUp).Row

plettieri
 
Upvote 0
Hi:

I tested it and seems to be ok..except for paper size...but maybe that is unique to your printer...

Do you have any cells , rows, colums locked or protected in any way....

try it on a fresh work sheet and see what happens....

plettieri
 
Upvote 0
It works just fine on my computer and I have the statement of ActiveSheet.Unprotect just to make sure. We are all pulling the same data so I can't figure out why it works on my computer and not everyone else's. Especially when it worked on another computer just two days ago!! Frustrating.....to say the least.
 
Upvote 0
Hi:


Maybe not making a difference but ....
All users running the same versions of excel?

plettieri
 
Upvote 0
Only problem I had was the paper size setting.

Is this the actual code that is causing problems or pieces cobbled together? The reason I ask is that the whole selection.font statement seems totally out of place and does nothing of value.

HT
 
Upvote 0
Paper size setting is specific to Xerox printer so I wouldn't expect that to work. The code that is used on my machine is the same that was copied to the other machines running the same version of Excel so I am still perplexed as to why it doesn't work.
 
Upvote 0
This may be too obvious, but are the other users configured to print to the same printer? Do thay have the same printer dirvers installed as you? Can you manually accomplish the same thing on all PCs so that we know that it is the code that is the problem? Sorry if you've already tried these things.
 
Upvote 0
That's one of the first things I checked to make sure they had the same printer configuration, but I will check this again. Thanks for racking your brain on this one. It's truly frustrating especially since it DID work one day on another computer. That REALLY has me perplexed!
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,266
Members
448,558
Latest member
aivin

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