I need to store some cell values into an array of variants. (I'm using this array in a for each loop, so it has to be variant) The following code gives a type mismatch error. Could someone please show me how to do it? Thanks in advance.
Public Sub MainSub()
Dim ws_names() As Variant
ws_names = Worksheets("Lookup").Range("K3:K5")
ShowCertainWorksheets ws_names
End Sub
Public Sub ShowCertainWorksheets(ByVal ws_names As Variant)
Dim ws_name As Variant
For Each ws_name In ws_names
ThisWorkbook.Worksheets(ws_name).Visible = True
Next ws_name
End Sub
Worksheets("Lookup").Range("K3:K5") contains only worksheet names that exist in the file so there's no problem there...
No comments:
Post a Comment