FillDown in VBA

ldashev

New Member
Joined
Mar 24, 2016
Messages
49
Hi,

Can someone please help...I have a macro where an input box prompts a user to input a single date...it's only a single date that needs to be copied down based on the length of an adjacent column:

myResponse = InputBox("Date EMAIL Recieved in MM-DD-YYYY Format")
Range("F2") = myResponse
Range("F2").Select
'Paste down
Dim lastRowFF As Long
lastRow = Range("G" & Rows.Count).End(xlUp).Row
Range("F2").AutoFill Destination:=Range("F2:F" & lastRow)

This doesn't work because the dates are auto filled so you get:


12-31-2016 (Cell F2)
01-01-2017
01-02-2017
01-03-2017
01-04-2017

<tbody>
</tbody>

What I'm looking to do with .filldown is

12-31-2016 (F2)
12-31-2016
12-31-2016
12-31-2016
12-31-2016

<tbody>
</tbody>

I tried applying this, but it didn't work:


myResponse = InputBox("Date EMAIL Recieved in MM-DD-YYYY Format")
Range("F2") = myResponse
Range("F2").Select
'Paste down
Dim lastRowFF As Long
lastRow = Range("G" & Rows.Count).End(xlUp).Row
Range("F2").FillDown Destination:=Range("F2:F" & lastRow)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi

If I understand correctly what you want is to copy, not to fill down.

Try:

Code:
Sub CopyDown()
Dim myResponse As Variant
Dim lastRow As Long

myResponse = InputBox("Date EMAIL Recieved in MM-DD-YYYY Format")
Range("F2") = myResponse

lastRow = Range("G" & Rows.Count).End(xlUp).Row

'Paste down
Range("F2").Copy Destination:=Range("F2:F" & lastRow)

End Sub
 
Upvote 0
Notice that you could also write the value directly in the range:

Code:
Sub CopyDown()
Dim myResponse As Variant
Dim lastRow As Long

myResponse = InputBox("Date EMAIL Recieved in MM-DD-YYYY Format")

lastRow = Range("G" & Rows.Count).End(xlUp).Row

Range("F2:F" & lastRow).Value = myResponse

End Sub
 
Upvote 0
Perfect! That worked! Thanks

Notice that you could also write the value directly in the range:

Code:
Sub CopyDown()
Dim myResponse As Variant
Dim lastRow As Long

myResponse = InputBox("Date EMAIL Recieved in MM-DD-YYYY Format")

lastRow = Range("G" & Rows.Count).End(xlUp).Row

Range("F2:F" & lastRow).Value = myResponse

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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