Date Autofill from Input Box

DAyotte

Board Regular
Joined
Jun 23, 2011
Messages
84
Hello All (again)
So, the macro I'm working on is working great, except for the date autofill.

The macro has an inputbox that requests the date of report from the user. This is manually entered into a textbox. Instead of filling the same date to the last used row, it goes up in incriments of years. IE: (A1) 04/01/2013, (A2) 04/01/2014, (A3) 04/01/2015, etc.

I was thinking a Copy/Paste to the last row would work, but I can't figure out how to do that. ("DateOK" is the name of my OK button, and "ReportDate" is the name of the textbox.)

Thanks again!

Here's my code:

Code:
 Private Sub DateOK_Click()  Range("A2").Value = ReportDate
  Range("A2").AutoFill Destination:=Range("A2:A" & Range("B" & Rows.Count) _
    .End(xlUp).Row), Type:=xlFillSeries
      Application.CutCopyMode = False
    ReportDate = Empty
  DateForm.Hide
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
The code seems to work fine when I try it.

The values aren't actually dates as you've just put the text from ReportDate in A2.

If you actually want dates first you'll need to convert the value in the textbox to a date using DateValue or CDate.

Also, to increment by years, you can use DataSeries.

Code:
Private Sub DateOK_Click()

    Range("A2").Value = DateValue(ReportDate)
    Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row).DataSeries Rowcol:=xlColumns, Type:=xlChronological, Date:= _
                                                                     xlYear, Step:=1, Trend:=False
    Application.CutCopyMode = False
    ReportDate = Empty

End Sub
 
Upvote 0
My fault for not specifying - The fact that it's change the years as it goes down is the issue. I want it to autofill the same date to the last used row. I removed the xlFillSeries, and there was no change. I also tried changing the .AutoFill (method?) to .FillDown, but it wasn't recognized.
 
Upvote 0
Did you try the code I posted?
 
Upvote 0
What exactly do you want to do?

If you just want the same date in all the cells get rid of all the AutoFill DataSeries stuff and use this.
Code:
    Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row).Value = ReportDate
 
Upvote 0

Forum statistics

Threads
1,214,397
Messages
6,119,273
Members
448,883
Latest member
fyfe54

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