D
Dandelo
I have a macro that uses Autofill to fill a formula down to the last row of
data. but when there is only 1 single row of data, this error message
appears:
Run-time error '1004'
Autofill Method of Range class failed
I know I need to add something to handle this error, but I can't seem to
find the right combination of Error handling syntax for the code in the
macro. The debug points to this piece of the macro:
Selection.AutoFill _
Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault
Below is the code that is working unless there is only a single row of data.
Any help is greatly appreciated, thank you.
Dim LastRow As Long
'Remove the decimal fields from the amount
'Multiply Cell B2 by 100
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-1]*100"
'Fill in the formula to the last row of data
'I got this code from Dave Peterson's 11/20/07 post from thread
"Autofill in macr"
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("B2").Select
Selection.AutoFill _
Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault
End With
data. but when there is only 1 single row of data, this error message
appears:
Run-time error '1004'
Autofill Method of Range class failed
I know I need to add something to handle this error, but I can't seem to
find the right combination of Error handling syntax for the code in the
macro. The debug points to this piece of the macro:
Selection.AutoFill _
Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault
Below is the code that is working unless there is only a single row of data.
Any help is greatly appreciated, thank you.
Dim LastRow As Long
'Remove the decimal fields from the amount
'Multiply Cell B2 by 100
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-1]*100"
'Fill in the formula to the last row of data
'I got this code from Dave Peterson's 11/20/07 post from thread
"Autofill in macr"
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("B2").Select
Selection.AutoFill _
Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault
End With