Hi all,
I have an autofill macro that copies a formula in one cell to all the cells in a defined range.
Currently, I manually edit the macro each time I'm using a unqiue range, but I feel like there is a more efficient way to do this. Any ideas? Is it possible to create a dialogue box that allow me to select the range?Sub autofill() 'autofills a formula through range ' Range("m3961").autofill Destination:=Range("m3961:m7921"), Type:=xlFillDefault End Sub
Thanks in advance for the help.
Cheers!
Something like this
Dim rFill As Range On Error Resume Next Application.DisplayAlerts = False Set rFill = Application.InputBox(Prompt:= _ "Please select a range with your Mouse to be bolded.", _ Title:="SELECT RANGE", Type:=8) On Error GoTo 0 Application.DisplayAlerts = True If rRange Is Nothing Then Exit Sub Else: Range("m3961").autofill Destination:=rfill, Type:=xlFillDefault End If
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Roy --- this is great! However, I'm still struggling a bit. When I went to run the macro, I received aThis is the code:'424' run-time object required
I'm sure I did something to make a bit of a hash of it, but I'm not sure what. Any ideas?Sub autofill() 'autofills a formula through range ' Dim rFill As Range On Error Resume Next Application.DisplayAlerts = False Set rFill = Application.InputBox(Prompt:= _ "Please select a range with your Mouse to be bolded.", _ Title:="SELECT RANGE", Type:=8) On Error GoTo 0 Application.DisplayAlerts = True If rRange Is Nothing Then Exit Sub Else: Range("a2").autofill Destination:=rFill, Type:=xlFillDefault End If End Sub
Try keeping your original macro as is, I would change the name from autofill() to myautofill() to avoid possible problems, then
add this macro to call it
sub getRange() Dim rFill As Range On Error Resume Next Application.DisplayAlerts = False Set rFill = Application.InputBox(Prompt:= _ "Please select a range with your Mouse to be bolded.", _ Title:="SELECT RANGE", Type:=8) On Error GoTo 0 Application.DisplayAlerts = True If rRange Is Nothing Then Exit Sub Else: myautofill End If End Sub
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks