Selecting Rows based on data

JTL9161

Well-known Member
Joined
Aug 29, 2012
Messages
582
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet where the data in column "D" today's date -1 (yesterday) and column 'J" has dates 1/1/19, 2/1/19, 3/1/19..etc.

I need to add to the bottom of my current macro something that finds the first cell with yesterday's date in column "D" and with 1/1/19 in column "J" and select the ROWS down to last cell with 1/1/19 or the cell above the cell that has 2/1/19 in it. Below is what I am looking for. The (entire) rows in red selected.









<colgroup><col style="mso-width-source:userset;mso-width-alt:3657;width:75pt" width="100"> <col style="mso-width-source:userset;mso-width-alt:3364;width:69pt" width="92"> <col style="mso-width-source:userset;mso-width-alt:3876;width:80pt" width="106"> <col style="mso-width-source:userset;mso-width-alt:2304;width:47pt" width="63"> <col style="mso-width-source:userset;mso-width-alt:3913;width:80pt" width="107"> <col style="mso-width-source:userset;mso-width-alt:2779;width:57pt" width="76"> <col style="mso-width-source:userset;mso-width-alt:4059;width:83pt" width="111"> <col style="mso-width-source:userset;mso-width-alt:3730;width:77pt" width="102"> </colgroup><tbody>
[TD="class: xl45879, width: 100"]XXXXX[/TD]
[TD="class: xl45878, width: 92"]2/4/2019[/TD]
[TD="class: xl45878, width: 106"]2/5/2019[/TD]
[TD="class: xl45879, width: 63"]Future[/TD]
[TD="class: xl45883, width: 107"]1[/TD]
[TD="class: xl45883, width: 76"]1[/TD]
[TD="class: xl45879, width: 111"]VA[/TD]
[TD="class: xl45878, width: 102"]3/1/2019[/TD]

[TD="class: xl45879"][/TD]
[TD="class: xl45878"]2/4/2019[/TD]
[TD="class: xl45878"]2/5/2019[/TD]
[TD="class: xl45879"]Future[/TD]
[TD="class: xl45883"]1[/TD]
[TD="class: xl45883"]1[/TD]
[TD="class: xl45879"]PA[/TD]
[TD="class: xl45878"]3/1/2019[/TD]

[TD="class: xl45879"]XXXXX[/TD]
[TD="class: xl45878"]2/4/2019[/TD]
[TD="class: xl45878"]2/5/2019[/TD]
[TD="class: xl45879"]Future[/TD]
[TD="class: xl45883"]1[/TD]
[TD="class: xl45883"]1[/TD]
[TD="class: xl45879"]FL[/TD]
[TD="class: xl45878"]3/1/2019[/TD]

[TD="class: xl45880"]
[/TD]
[TD="class: xl45881"] 2/5/2019 [/TD]

[TD="class: xl45880"] Retro [/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45880"] PA [/TD]
[TD="class: xl45881"] 1/1/2019 [/TD]

[TD="class: xl45880"] XXXXX [/TD]
[TD="class: xl45881"] 2/5/2019 [/TD]

[TD="class: xl45880"] Retro [/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45880"] IL [/TD]
[TD="class: xl45881"] 1/1/2019 [/TD]

[TD="class: xl45880"] XXXXX [/TD]
[TD="class: xl45881"] 2/5/2019 [/TD]

[TD="class: xl45880"] Retro [/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45880"] FL [/TD]
[TD="class: xl45881"] 1/1/2019 [/TD]

[TD="class: xl45880"] XXXXX [/TD]
[TD="class: xl45881"] 2/5/2019 [/TD]

[TD="class: xl45880"] Retro [/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45880"] IL [/TD]
[TD="class: xl45881"] 1/1/2019 [/TD]

[TD="class: xl45880"] XXXXX [/TD]
[TD="class: xl45881"] 2/5/2019 [/TD]

[TD="class: xl45880"] Retro [/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45880"] IL [/TD]
[TD="class: xl45881"] 1/1/2019 [/TD]

[TD="class: xl45880"] XXXXX [/TD]
[TD="class: xl45881"] 2/5/2019 [/TD]

[TD="class: xl45880"] Retro [/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45880"] IL [/TD]
[TD="class: xl45881"] 1/1/2019 [/TD]

[TD="class: xl45880"] XXXXX [/TD]
[TD="class: xl45881"] 2/5/2019 [/TD]

[TD="class: xl45880"] Retro [/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45883"]
[/TD]
[TD="class: xl45880"] IL [/TD]
[TD="class: xl45881"] 1/1/2019 [/TD]

[TD="class: xl45880"]XXXXXXXXXX[/TD]
[TD="class: xl45881"]2/5/2019[/TD]

[TD="class: xl45880"]Retro[/TD]
[TD="class: xl45883"][/TD]
[TD="class: xl45883"][/TD]
[TD="class: xl45880"]MO[/TD]
[TD="class: xl45881"]2/1/2019[/TD]

[TD="class: xl45880"]XXXXXXXXX[/TD]
[TD="class: xl45881"]2/5/2019[/TD]

[TD="class: xl45880"]Retro[/TD]
[TD="class: xl45883"][/TD]
[TD="class: xl45883"][/TD]
[TD="class: xl45880"]CT[/TD]
[TD="class: xl45881"]2/1/2019
[/TD]

</tbody>

Hope my explaination is to confusing.
Thank you,
James
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
"I need to add to the bottom of my current macro something..." -- You might ought to post YOUR EXISTING MACRO too..
 
Upvote 0
Hi there, you can try something like this:

Code:
Dim MyDate As Date
Dim frow As Long
Dim lrow As Long
Dim rngFound As Range
Dim sFirst As String

MyDate = Date - 1

Set rngFound = Columns("D").Find(MyDate, Cells(Rows.Count, "D"), xlValues, xlWhole)
If Not rngFound Is Nothing Then
    sFirst = rngFound.Address
    Do
        If Cells(rngFound.Row, "J").Value = "1/1/2019" Then
            frow = rngFound.Row
        End If
        Set rngFound = Columns("D").Find(MyDate, rngFound, xlValues, xlWhole)
        lrow = rngFound.Row
    Loop While rngFound.Address <> sFirst
End If

Range("D" & frow, "D" & lrow).EntireRow.Select

Set rngFound = Nothing
 
Upvote 0
Thanks for your input. I will give it a try.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top