#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Code Help

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Code Help

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


--
JB


"Scott Halper" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Code Help

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

"Scott Halper" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) Thulasiram[_2_] Excel Programming 4 September 26th 06 04:15 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 01:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"