Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Hiding unused columns



Howdie,

Im trying to go from column BY all the way to the left till first column
of data is found. Then hide all columns one to the right of the last
found column.
Eg data in column g, then want to hide H to BY. (columns with data will
vary. End point is always BY)

VB below almost works - it just hides last column with data in it (ie
column G) as well, and I need it to hide column H

Sub test

Application.Goto Reference:="R1C77"
Columns("BY:BY").Select
Range(selection, selection.End(xlToLeft)).Select
selection.EntireColumn.Hidden = True

End sub

Thanks

Darin



*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Hiding unused columns

Sub test()

Range(Range("BY1"), Range("BY1").End(xlToLeft)).Offset(0,
1).EntireColumn.Hidden = True

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Darin Kramer" wrote in message
...


Howdie,

Im trying to go from column BY all the way to the left till first column
of data is found. Then hide all columns one to the right of the last
found column.
Eg data in column g, then want to hide H to BY. (columns with data will
vary. End point is always BY)

VB below almost works - it just hides last column with data in it (ie
column G) as well, and I need it to hide column H

Sub test

Application.Goto Reference:="R1C77"
Columns("BY:BY").Select
Range(selection, selection.End(xlToLeft)).Select
selection.EntireColumn.Hidden = True

End sub

Thanks

Darin



*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Hiding unused columns

Hi Darin

Just put in an offset of 1 column and resize by 1 less than your column
count, to prevent BZ getting hidden instead.

Sub test()

Application.Goto Reference:="R1C77"
Columns("BY:BY").Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Offset(0, 1).Resize(1, Selection.Columns.Count - 1).Select
Selection.EntireColumn.Hidden = True

End Sub

--
Regards

Roger Govier


"Darin Kramer" wrote in message
...


Howdie,

Im trying to go from column BY all the way to the left till first
column
of data is found. Then hide all columns one to the right of the last
found column.
Eg data in column g, then want to hide H to BY. (columns with data
will
vary. End point is always BY)

VB below almost works - it just hides last column with data in it (ie
column G) as well, and I need it to hide column H

Sub test

Application.Goto Reference:="R1C77"
Columns("BY:BY").Select
Range(selection, selection.End(xlToLeft)).Select
selection.EntireColumn.Hidden = True

End sub

Thanks

Darin



*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Hiding unused columns



Thanks!!! Works Perfectly!

*** Sent via Developersdex http://www.developersdex.com ***
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
How can i delete unused row and columns ??? Irfan Khan[_2_] Excel Discussion (Misc queries) 8 January 15th 08 07:26 PM
hiding unused categories in charts Compensation Analyst Excel Discussion (Misc queries) 1 March 19th 07 09:22 PM
Having a floating row or hiding unused rows? Simon Lloyd[_764_] Excel Programming 5 June 14th 06 09:45 PM
Deleting unused columns dramajuana Excel Discussion (Misc queries) 2 June 11th 06 12:14 AM
After hiding unused columns to the right, border on right disappea Oldemom Excel Discussion (Misc queries) 0 January 17th 06 03:16 PM


All times are GMT +1. The time now is 11:15 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"