Code Help

S

Scott Halper

I have the code below and I keep getting this error meesage, "Select
Method of Range Class failed". I am trying to just side some column
when a user clicks a button.


Private Sub FirstChooser_Click()
Application.ScreenUpdating = False
Sheets("Model").Select
Columns("P:Q").Select
Selection.EntireColumn.Hidden = True
Columns("S:T").Select
Selection.EntireColumn.Hidden = True
Range("O56").Select
Application.ScreenUpdating = True
End Sub

Thanks for the help.

Scott
 
J

john

try following (not tested)

Private Sub FirstChooser_Click()
Application.ScreenUpdating = False
With Worksheets("Model")
.Activate
.Columns("P:Q").EntireColumn.Hidden = True
.Columns("S:T").EntireColumn.Hidden = True
.Range("O56").Select
End With
Application.ScreenUpdating = True
End Sub
 
B

Bob Flanagan

Your code works fine for me. Are you in the workbook containing sheets
"model"? Do you have a chart selected by any chance? Which line is failing?
What version of Excel are you using? There was a problem quite a while ago
with the button taking the focus. Try adding the line "selection.activate"
as the first line.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top