I'm trying to create a series of macros that determine variables to be used in another macro. The latter macro involves looping through columns, so I'm using a Cells property reference for one of the variables, but when I try to run it I get a Run-time error '1004' (Application-defined or object-defined error). How can I properly set the variable for cond1?
Preliminary macro:
Target macro:
Preliminary macro:
Code:
Dim cond1 As Range
Dim cond2 As Range
Sub Scenario1()
If Range("E7") = "All" And Range("E5") = "All" Then
Set cond1 = Cells(13, curCol)
Set cond2 = Range("E6")
Application.Run "View"
End If
End Sub
Code:
Sub View()
Dim fCell As Range
Set fCell = Range("I5")
With Sheets("Employees")
Do Until fCell.Value = ""
curCol = fCell.Column
fCell.Select
With fCell.EntireColumn
If cond1 <> cond2 Then
.Hidden = True
Else
.Hidden = False
End If
End With
Set fCell = fCell.Offset(0, 1)
Loop
Range("B3").Select
End With
End Sub