Wednesday 1 May 2019

excel - convert cells in to an array of variant

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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...