VBA Macro to Fill Down a column(s) with the same data

Ovisele

New Member
Joined
Apr 28, 2015
Messages
30
First of all, thank you for taking the time to read this.

To keep it simple, is there a simple code line(s) that allow me to fill down automatically one column, with the value from a specific cell (I3 here), until the end of data (variable number of rows)? I have 600 files and the number of lines that need to be filled varied from 2 to 80+.

I have tried this lines but
It returns an error Argument not optional for the Autofill.

Sub Test()
Dim ws As Worksheet
Set ws = Worksheets("Calculus")
With
ws Range("I3").AutoFill Range ("I4:I" & ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)
End With

0N1W4cS
0N1W4cS
Thank you very much!
0N1W4cS
96b1bbc4d41d61a37b4e2b2d855e4648-full.jpg
 
I do not get the any error but the fill down is not working any more. Full code below, maybe it is easier this way.

Sub FillDown()


Dim xFd As FileDialog
Dim xFdItem As Variant
Dim xFileName As String
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
If xFd.Show = -1 Then
xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
xFileName = Dir(xFdItem & "*.xls*")
Do While xFileName <> ""
With Workbooks.Open(xFdItem & xFileName)
'your code here
If lr > 1 Then
lc = Cells(3, Columns.Count).End(xlToLeft).Column - 8
lr = Cells(Rows.Count, "h").End(xlUp).Row - 2
Range("I3:m3").AutoFill Cells(3, 9).Resize(lr, lc)
End If
ActiveWorkbook.Save
ActiveWorkbook.Close
End With
xFileName = Dir
Loop
End If
End Sub
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
See this part
Code:
lc = Cells(3, Columns.Count).End(xlToLeft).Column - 8
lr = Cells(Rows.Count, "h").End(xlUp).Row - 2
[COLOR=#ff0000]If lr > 1 Then[/COLOR]
Range("I3:m3").AutoFill Cells(3, 9).Resize(lr, lc)
 
Upvote 0
You are very well come
Thank you for the feedback
Be happy
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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