Thread: Many columns
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Many columns

In my old job, I had a similar problem. Although it may be rather kludge-y,
we ended up highlighting the various "views" with different background
colors. Then I wrote a macro to hide or unhide rows and columns depending on
the background color of the cell that was currently selected when the macro
was run.

In our situation, the different scenarios headers were found somewhere in
rows 1 to 15, and the data entry started on row 16. You may need to adjust
this code slightly to better fit your need. Hope it helps.

Public Sub DoTemplate()

Dim objWS As Excel.Worksheet
Dim objCell As Excel.Range, objR As Excel.Range
Dim I As Byte, K As Byte
Dim J As Long

Set objWS = ActiveWorkbook.ActiveSheet
Set objCell = Application.Selection

K = objCell.Row
J = objCell.Interior.ColorIndex

' Hide rows
For I = 2 To 15

If I < K Then

objWS.Rows(I).Hidden = True

End If

Next

' Hide columns
For I = 1 To 167

Set objR = objWS.Cells(K, I)
If objR.Interior.ColorIndex < J Then

objWS.Columns(I).Hidden = True

End If

Next

Set objR = Nothing
Set objCell = Nothing
Set objWS = Nothing

End Sub
--
Hmm...they have the Internet on COMPUTERS now!


"Darin Kramer" wrote:



Hi Guys,

I have data within columns a to d which is static.
From Columns e onwards to say az there is a variety of information which
needs to be entered on a row by row basis. It is rather time consuming
to write macros to hide and unhide columns depedning on the view
required. Is there any easier way of group (ie viewing) columns? (eg I
want to see columns a - d, and h - k, for purposes of data entry 1, and
then to enter data set 2, I need to see A - d and m - q), and all
others hidden).

Kind Regards

D

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