rahulbassi268
New Member
- Joined
- Sep 23, 2016
- Messages
- 14
Hello Gurus,
Kindly help me to understand where am I going wrong here.
I have a listobject (Table) with 2 columns. I want to get table rownumbers (row number in dataBodyRange; Not worksheet row number) in array where DataType(2nd column) is "Date"
But, my loop in below code is always stuck at row number 3 i.e. Hire_Date.
If databodyrange row number is not possible, then corresponsing value in first column would be fine.
All I need is the result in an array.
Below is my code
Kindly help me to understand where am I going wrong here.
I have a listobject (Table) with 2 columns. I want to get table rownumbers (row number in dataBodyRange; Not worksheet row number) in array where DataType(2nd column) is "Date"
But, my loop in below code is always stuck at row number 3 i.e. Hire_Date.
If databodyrange row number is not possible, then corresponsing value in first column would be fine.
All I need is the result in an array.
Below is my code
VBA Code:
Dim SetupListObj As ListObject
Dim LocateDate As Range
Dim date_fields() As Variant
Set SetupListObj = ActiveSheet.ListObjects("MyTable")
Set LocateDate = SetupListObj.ListColumns(2).DataBodyRange
For Each setup_cell In LocateDate
MsgBox setup_cell.Value
If setup_cell.Value = "Date" Then
' setup_row = SetupListObj.ListColumns(2).DataBodyRange.Range(setup_cell).Row
MsgBox "setup_row " & SetupListObj.ListColumns(2).DataBodyRange.Row & " - " & SetupListObj.ListColumns(1).DataBodyRange(setup_row, 1).Value
count = count + 1
ReDim Preserve date_fields(count)
' date_fields(count) = SetupListObj.ListColumns(1).DataBodyRange(setup_row, 1).Value
date_fields(count) = setup_row
End If
Next setup_cell