My loop works for the first J but fail on the 2nd iteration and I can not figure out why
Thanks
Sub RCFLB_n()
RCFLB "XXX", Array("What", "Where", "Why", "How")
End Sub
Sub RCFLB(shtName As String,Optional HNarr As Variant = "Col1")
Dim arrData() As Variant, arrReturnData() As Variant, CN As Variant
Dim ws As Worksheet
Dim LR As Long, LC As Long
Dim I As Long, J As Long
Set ws = ThisWorkbook.Sheets(shtName)
'Array of Column numbers coresponding to Header names
CN = CHTCN(shtName, HNarr)
With ws
LR = .Cells.Find("*", [a1], , , xlByRows, xlPrevious).Row
End With
ReDim arrReturnData(1 To LR, 1 To 1)
For J = 0 To UBound(CN)
Erase arrData
arrData = ws.Range(ws.Cells(1, CN(J)), ws.Cells(LR, CN(J))).Value
MsgBox arrData(1, CN(J))
Next J
'Stuff
End Sub
Bookmarks