Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-13-2017, 07:53 AM
OfficeAssociate99 OfficeAssociate99 is offline Using DateValue to find if a date exists within a certain range Windows 7 64bit Using DateValue to find if a date exists within a certain range Office 2010 64bit
Novice
Using DateValue to find if a date exists within a certain range
 
Join Date: May 2017
Posts: 19
OfficeAssociate99 is on a distinguished road
Default Using DateValue to find if a date exists within a certain range

Hi guys, I am trying to search through 5000+ rows to figure out if a date exists within a certain range. I am mostly self-taught, so I have difficulty with assigning correct object variables, etc. This is what I have so far:

Code:
Sub Search()
Dim i As Integer
Dim myDate1 As Integer
Dim myDate2 As Integer
Set r = Range(Range("A2"), Range("AF" & Rows.Count))
i = 2
For Each Row In r
    myDate1 = DateValue(r.Cells(i, 26).Value)
    myDate2 = DateValue(r.Cells(i, 29).Value)
    If myDate1 > 42312 = True And myDate2 > 42461 = True Then
       ThisWorksheet.Rows(i).EntireRow.Interior.ColorIndex = 3
    ElseIf myDate1 > 42460 = True And myDate2 > 42825 = True Then
        ThisWorksheet.Rows(i).EntireRow.Interior.ColorIndex = 3
    End If
    i = i + 1
Next Row
End Sub

Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Project 2016 print specific date range stuck on one date martinsalmon Project 1 10-12-2016 11:36 AM
Using DateValue to find if a date exists within a certain range Find if Date range falls within another range Triadragon Excel 3 05-02-2016 11:48 AM
Find a Date in a Range rspiet Excel 3 02-15-2016 08:37 AM
Check if a Date falls within a date range OTPM Excel 7 02-03-2016 09:11 PM
find IP in range / find number between numbers gn28 Excel 4 06-14-2015 03:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft