Originally Posted by
crazybass2
Place this code in the module for the sheet in question.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Target, Range("D3:BD3")) Is Nothing Then
For Each rng In Range("D3:BD3")
If rng <> "" Then Columns(rng.Column).Hidden = False
Next rng
End If
End Sub
Mike
Hi crazybass2,
Your code is great as a stand alone but i am having trouble putting it in this existing code,
Sub aTest()
'Unhide last used Column Based on row 3
'''Tried several variations, no luck
'''Tried changing the name and puting it outside this code with a call here, no luck
''' Dim rng As Range
''' If Not Intersect(Target, Range("D3:BD3")) Is Nothing Then
''' For Each rng In Range("D3:BD3")
''' If rng <> "" Then Columns(rng.Column).Hidden = False
''' Next rng
'Everything below here works ok
'Color cells with a zero to red
Dim rCell As Range
For Each rCell In Range("TheRange")
'Code to run on each cell
If rCell.Value = "0" Then
rCell.Interior.ColorIndex = 3
Else
rCell.Interior.ColorIndex = xlAutomatic
End If
Next rCell
'Format yellow (total) rows
Range("D14:BL14,D26:BL26,D37:BL37,D47:BL47,D57:BL57,D68:BL68,D79:BL79").Select
Selection.Interior.ColorIndex = 6
Selection.HorizontalAlignment = xlRight
Selection.VerticalAlignment = xlCenter
Selection.NumberFormat = "#,##0.00_);(#,##0.00)"
'Move window back to the top
ActiveWindow.SmallScroll Down:=-67
'and select cell
Range("A1").Select
End Sub
Bookmarks