jbenfrancis1
New Member
- Joined
- Feb 22, 2022
- Messages
- 11
- Office Version
- 365
- 2016
- Platform
- Windows
Hi, i have done a lot of searching and found some useful stuff but cannot piece it together to make it work. Here is my dilemma.
Sheet1 has data on it and the corresponding date.
Sheet2 has historical data on it with dates.
Sheet2 has column headers for each day so for example C6 is 2/21/2022, D6 is 2/20/2022 and so on all the way out to BJ6.
I am trying to write some code that will look at the date on Sheet1 and search for it on Sheet2 row 6. If they match, then add the data from Sheet1 2 rows below the date on Sheet2
This code allow it to search the range correctly and cycle through
Sheet1 has data on it and the corresponding date.
Sheet2 has historical data on it with dates.
Sheet2 has column headers for each day so for example C6 is 2/21/2022, D6 is 2/20/2022 and so on all the way out to BJ6.
I am trying to write some code that will look at the date on Sheet1 and search for it on Sheet2 row 6. If they match, then add the data from Sheet1 2 rows below the date on Sheet2
This code allow it to search the range correctly and cycle through
VBA Code:
Dim b As Range
Set b = Sheets("Sheet2").Range("C6:BJ6")
For Each c In Sheets("Sheet1").Range("C2")
If IsNumeric(Application.Match(c, b, 0)) Then
'I don't know what to put here to say stop and insert data once match is found
Exit Sub
End If
Next c