Hi Leo
Selecting in VBA should (and in most cases can) be avoided. Try this method
Sub ChangeAllformats()
Dim Sht As Worksheet
Dim ThisSheet As Worksheet
Application.ScreenUpdating = False
Set ThisSheet = ActiveSheet
For Each Sht In ThisWorkbook.Worksheets
Sht.Cells.Style = "Currency"
Next Sht
Application.ScreenUpdating = True
ThisSheet.Select
Set ThisSheet = Nothing
End Sub
Dave
OzGrid Business Applications
Sorry, Dave, I must be dense.....
.. but I can't figure which pieces of your code are to select all sheets/cells and which are to return to the original spot in the worksheet after the formatting changes are done. I guess what I want to do is insert the code for the formatting changes (e. g., turn off gridlines, erase borders, etc) between the starting and ending pieces of your code. I can't seem to make it work that way.
Leo, paste this code into a module for easier reading, then run it from your Worksheet.
Sub ChangeAllformats()
'Dimension variables
Dim Sht As Worksheet
Dim ThisSheet As Worksheet
'Stop screen flickering
Application.ScreenUpdating = False
'Set the Worsheet Variable "ThisSheet" Activesheet
Set ThisSheet = ActiveSheet
'Loop through all cell and turn off gridline, _
remove borders.
For Each Sht In ThisWorkbook.Worksheets
With Sht
.Activate 'Need to activate to turn off Gridlines
.Cells.Borders.LineStyle = xlLineStyleNone
End With
ActiveWindow.DisplayGridlines = False
Next Sht
'End of loop
Application.ScreenUpdating = True
ThisSheet.Select 'Finish on the sheet we started
Set ThisSheet = Nothing 'release memory
End Sub
I have put comments in the code to try and help you follow it.
Dave
OzGrid Business Applications
Dave:
Running the macro you supplied returned error message: "Run time error 1004:
Method 'Select' of Object '_Worksheet' failed."
I pasted directly from your post. Any thoughts?
I really appreciate the time you're taking.
Leo
Re: "Run Time" Error message
When you get the error, click Debug nad tell me which line of the code is highlighted.
Dave
OzGrid Business Applications
Highlighted line is: "ThisSheet.Select 'Finish on the sheet we started"
Leo. I'm unable to reproduce this error could I send you a small Workbook example ?
Dave
OzGrid Business Applications