I'm trying to iterate a table and get index from all rows which Cell (cell for date) at position A (column A) equals to some date which date i get from another cell lets say H1
cell. I have a button with attached macro on it when clicked.
The table has more than 10000 rows and have 7 columns ( A, B, C, D, E, F, G)
the A column represents date. In javascript it would be somthing like this.
All the cells inside column A have day/month/year values. And the whole table is for an year only. So the table starts from 01/01/2017 and will end at 31/12/2017.
const myDate = worksheet.getCell('H1').Value;
const columnA = worksheet.getColumns('A') // here i use pseudocode
columnA.forEach((cell, index) => {
if (cell.Value == myDate)
console.log(index); // instead i can push each index in array so later i could forEach the rows with these indexes and then do some manipulation.
});
My task basically is to put a date string into an H1 cell. And when button is clicked All the rows which first cell ( column A ) equals H1 cell must be printed.
Edited:
Tried this so far and i'm storing and indexes where the day starts and where it ends. So I have the range. Now how can I select all the cells which rows are between firstRow and lastRow and Print them out.
Sub FindMyNubmer()
Dim a As Range, b As Range
Dim firstRow As Long
Dim lastRow As Long
Set a = Range("A1:A65000")
For Each b In a.Rows
If b.Value = Range("H4").Value Then
If firstRow = "0" Then
firstRow = b.Row
End If
lastRow = b.Row
End If
Next
MsgBox firstRow & " - " & lastRow
End Sub