Selecting Rows based on data

JTL9161

Well-known Member
Joined
Aug 29, 2012
Messages
567
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.

XXXXX2/4/20192/5/2019Future11VA3/1/2019
2/4/20192/5/2019Future11PA3/1/2019
XXXXX2/4/20192/5/2019Future11FL3/1/2019

2/5/2019
Retro

PA1/1/2019
XXXXX2/5/2019
Retro

IL1/1/2019
XXXXX2/5/2019
Retro

FL1/1/2019
XXXXX2/5/2019
Retro

IL1/1/2019
XXXXX2/5/2019
Retro

IL1/1/2019
XXXXX2/5/2019
Retro

IL1/1/2019
XXXXX2/5/2019
Retro

IL1/1/2019
XXXXXXXXXX2/5/2019RetroMO2/1/2019
XXXXXXXXX2/5/2019RetroCT2/1/2019

<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>
</tbody>

Hope my explaination is to confusing.
Thank you,
James
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
"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,214,833
Messages
6,121,858
Members
449,051
Latest member
excelquestion515

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