OK thanks Stu that helped. It's still producing errors. This time "method 'Range' of object '_worksheet' failed".
Sub Hide_ProjectA()
'
' Hide_ProjectA Columns
' Hides columns outside a specified project date range
'Unhide all columns
Columns("C:BC").Hidden = False 'Unhide all week Columns
'If Target.Address = "$B$6:$B$7" Then
Dim the_selection_Before As String
Dim the_selection_After As String
Dim Week_review As String
the_selection_Before = Sheet1.Range("$B$6")
Dim Rep As Integer
For Rep = 3 To 54
the_column = GetColumnLetter_ByInteger(Rep)
Week_review = Sheet1.Range(the_column & "15")
If Week_review < the_selection_Before Then
Sheet1.Range(the_column & ":" & the_column).EntireColumn.Hidden = True
Else
Sheet1.Range(the_column & ":" & the_column).EntireColumn.Hidden = False
End If
Next Rep
the_selection_After = Sheet1.Range("$B$7")
Dim Rep2 As Integer
For Rep2 = 3 To 54
the_column = GetColumnLetter_ByInteger(Rep)
Week_review = Sheet1.Range(the_column & "4")
If Week_review > the_selection_After Then
Sheet1.Range(the_column & ":" & the_column).EntireColumn.Hidden = True
Else
End If
Next Rep2
'End If
Application.ScreenUpdating = True
End Sub
And the GetColumnLetter_ByInteger code:
Public Function GetColumnLetter_ByInteger(what_number As Integer) As String
GetColumnLetter_ByInteger = ""
MyColumn_integer = what_number
If MyColumn_integer <= 26 Then
colum_letter = Chr(64 + MyColumn_integer)
End If
If MyColumn_integer > 26 Then
column_letter = Chr(Int((MyColumn_integer - 1) / 26) + 64) & Chr(((MyColumn_integer - 1) Mod 26) + 65)
End If
GetColumnLetter_ByInteger = column_letter
End Function
Anyone have any ideas? I didn't imagine this would be such technical code. All I wanted was to his columns outside a users specified range. I'm not sure my code is even on the right path...
Bookmarks