I'm stuck at this one, which is probably easy to fix.
So far I have:
Sub ListSheets()
Dim ws As Worksheet
Dim x As Integer
x = 1
Sheets("Lijst medewerker").Range("A:A").Clear
For Each ws In Worksheets
Sheets("Lijst medewerker").Cells(x, 1) = ws.Name
x = x + 1
Next ws
Dim LastRow As Long
Dim str As String
str = Cells(2, 1).Value
With Sheets("Lijst medewerker")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("B2:B" & LastRow)
.Formula = "=VLOOKUP($B$1,'" & str & "'!C:H,6,FALSE)"
End With
End With
End Sub
Now the problem is: The VLOOKUP formula in B2:B has to change the Worksheet name (in A2:A) but keeps returning the sheet name in A2. The str part is wrong but I don't know how to fix this.
Does anyone have a solution? I'm not an expert in VBA programming so excuse me if this code is crap so far....
Bookmarks