Adding one day to a date, in a loop, until reaching the end date of the Month.

jbumps

New Member
Joined
Dec 18, 2012
Messages
10
Hi All. Usually I'm able to review others' previous questions and patch together a useable Macro. Today, however, is a different story.

I have a beginning date that I'm finding via the following (search for the first blank cell in the column, then set over one column to the left to find the associated date).

Range("b3").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Select

From here I'd like to take that value and use it in a loop in a fashion similar to:

For x = (date found above) to (end day of the current month, as of the date found above)

"X" would be inserted into this (along with a lot of trailing code that I'll spare you):

Sheets("Data Drop").Select
Range("B1").Select
Application.CutCopyMode = False
Selection.AutoFilter

Selection.AutoFilter
ActiveSheet.Range("$A$1:$M$2888").AutoFilter Field:=13, Criteria1:="DS"
ActiveSheet.Range("$A$1:$M$2888").AutoFilter Field:=3, Criteria1:= _
"=GR for order", Operator:=xlOr, Criteria2:="=GR for order rev."
ActiveSheet.Range("$A$1:$M$2888").AutoFilter Field:=10, Criteria1:=X

Next x
Calculate



Thanks in advance to anyone able to offer up some direction!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Perhaps something like this...

Code:
    [color=darkblue]Dim[/color] StartDate [color=darkblue]As[/color] Date, d As Date
    StartDate = Range("B" & Rows.Count).End(xlUp).Value
    [color=darkblue]With[/color] Sheets("Data Drop")
        [color=darkblue]If[/color] .FilterMode [color=darkblue]Then[/color] .ShowAllData
        [color=darkblue]For[/color] d = StartDate [color=darkblue]To[/color] DateSerial(Year(StartDate), Month(StartDate) + 1, 0) [color=green]'Last day of the month[/color]
            .Range("A1:M2888").AutoFilter Field:=13, Criteria1:="DS"
            .Range("A1:M2888").AutoFilter Field:=3, Criteria1:= _
                "=GR for order", Operator:=xlOr, Criteria2:="=GR for order rev."
            ActiveSheet.Range("A1:M2888").AutoFilter Field:=10, Criteria1:=d
        [color=darkblue]Next[/color] d
    [color=darkblue]End[/color] [color=darkblue]With[/color]
 
Upvote 0
Code:
Range("b3").Select
Do
  If Not IsEmpty(ActiveCell) Then ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell) = True
StartDate = ActiveCell.Offset(, -1).Value
'From here I'd like to take that value and use it in a loop in a fashion similar to:
For x = StartDate To DateSerial(Year(StartDate), Month(StartDate) + 1, 1) - 1

  '"X" would be inserted into this (along with a lot of trailing code that I'll spare you):
Next x

?
 
Upvote 0
Code:
Range("b3").Select
Do
  If Not IsEmpty(ActiveCell) Then ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell) = True
StartDate = ActiveCell.Offset(, -1).Value
'From here I'd like to take that value and use it in a loop in a fashion similar to:
For x = StartDate To DateSerial(Year(StartDate), Month(StartDate) + 1, 1) - 1

  '"X" would be inserted into this (along with a lot of trailing code that I'll spare you):
Next x

?

Is the ? directed to me or the first responder? If myself, please let me know what I can clarify and I'll do my best.

Thanks,
 
Upvote 0
Is the ? directed to me or the first responder? If myself, please let me know what I can clarify and I'll do my best.
Thanks,
You. It's instead of starting 'Perhaps'. An offering that may or may not fit the bill. Nothing to clarify.
 
Upvote 0
You. It's instead of starting 'Perhaps'. An offering that may or may not fit the bill. Nothing to clarify.

Wow - very sorry. That went way over my head and shouldn't have. Once I get a chance to review the suggestions I'll leave some feedback.

Thanks to both of you!
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

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