Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default display only columns A to I

I want users to be able to see only columns A to I. The following
code works in the worksheet_selectionchange() but I don't want it
to execute everytime users make a change on the sheet. If I put
the code in a module, no column is visible. The sheet is
completely blank. Any help?


Sheets("sheet1").Columns.Hidden = True
Sheets("sheet1").Columns("A:I").Hidden = false
Sheets("sheet1").Columns("A:I").Show
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default display only columns A to I

Your code works fine for me.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"John Smith" wrote in message
...
I want users to be able to see only columns A to I. The following
code works in the worksheet_selectionchange() but I don't want it
to execute everytime users make a change on the sheet. If I put
the code in a module, no column is visible. The sheet is
completely blank. Any help?


Sheets("sheet1").Columns.Hidden = True
Sheets("sheet1").Columns("A:I").Hidden = false
Sheets("sheet1").Columns("A:I").Show



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default display only columns A to I

Chip Pearson wrote:

Your code works fine for me.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default display only columns A to I

Where did you put the code? I put it in a module and got a blank sheet,
no columns, no rows, no cells. When I followed the instruction on your
web site (BTW, a great site with good info) and progamatically put it in
workbook_activate() or worksheet_activate(), same blank sheet I got. It
only works when I put it in worksheet_selectionchange() but I think the
code should be executed only once, not every time people click on the
worksheet.

Chip Pearson wrote:

Your code works fine for me.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default display only columns A to I

In a module put:

Sub Macro1()
Columns("A:IV").EntireColumn.Hidden = False
Columns("J:IV").EntireColumn.Hidden = True
End Sub


In worksheet code for sheet1 put:

Private Sub Worksheet_Activate()
Call Macro1
End Sub
--
Gary's Student


"John Smith" wrote:

I want users to be able to see only columns A to I. The following
code works in the worksheet_selectionchange() but I don't want it
to execute everytime users make a change on the sheet. If I put
the code in a module, no column is visible. The sheet is
completely blank. Any help?


Sheets("sheet1").Columns.Hidden = True
Sheets("sheet1").Columns("A:I").Hidden = false
Sheets("sheet1").Columns("A:I").Show



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default display only columns A to I

Put in the Worksheet_Activate event.
Private Sub Worksheet_Activate()
Sheets("sheet1").Columns("J:IV").Hidden = True
End Sub

If they unhide the columns manually, you can re-hide them with this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheets("sheet1").Columns("J").Hidden = False Then
Sheets("sheet1").Columns("J:IV").Hidden = True
Else: Exit Sub
End If
End Sub

Mike F

"John Smith" wrote in message
...
I want users to be able to see only columns A to I. The following
code works in the worksheet_selectionchange() but I don't want it
to execute everytime users make a change on the sheet. If I put
the code in a module, no column is visible. The sheet is
completely blank. Any help?


Sheets("sheet1").Columns.Hidden = True
Sheets("sheet1").Columns("A:I").Hidden = false
Sheets("sheet1").Columns("A:I").Show



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default display only columns A to I

Thanks to Don and Mike. Your suggestions work great.

Mike Fogleman wrote:

Put in the Worksheet_Activate event.
Private Sub Worksheet_Activate()
Sheets("sheet1").Columns("J:IV").Hidden = True
End Sub

If they unhide the columns manually, you can re-hide them with this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheets("sheet1").Columns("J").Hidden = False Then
Sheets("sheet1").Columns("J:IV").Hidden = True
Else: Exit Sub
End If
End Sub

Mike F

"John Smith" wrote in message
...


I want users to be able to see only columns A to I. The following
code works in the worksheet_selectionchange() but I don't want it
to execute everytime users make a change on the sheet. If I put
the code in a module, no column is visible. The sheet is
completely blank. Any help?


Sheets("sheet1").Columns.Hidden = True
Sheets("sheet1").Columns("A:I").Hidden = false
Sheets("sheet1").Columns("A:I").Show






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
display columns alphabetically Grocer New Users to Excel 0 September 21st 09 06:51 PM
How can I group and display columns automatically? faraz316 Excel Worksheet Functions 3 June 30th 09 03:27 AM
Compare columns and display the value Raj Excel Discussion (Misc queries) 1 December 29th 08 09:49 AM
Scrolling columns display [email protected] Excel Programming 0 December 6th 05 11:38 AM
compare two columns and display a third ch90 Excel Discussion (Misc queries) 4 October 13th 05 12:56 PM


All times are GMT +1. The time now is 02:12 AM.

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"