jennifer george
asked on
Run-time error '1004': autofill method of range class failed.
Hi all -
Need a quick fix for this macro.
It was working & has quit. I commented out the original code & tried the "lastrow". Obviously, I have screwed up how it should be - and my VB skills are bad @ best...
Any help would be greatly appreciated!
Thank you!
Dim lastrow As Long
lastrow = Range("Y65000").End(xlUp). Row
'Copy formulas
Sheets("DDC Checklist").Select
Range("Y7:AI7").Select
'Selection.AutoFill Destination:=Range("Y7:AI5 06")
Selection.AutoFill Destination:=Range("Y7:Y" & lastrow)
Range("Y7:AI506").Select
'Select Range A1 on DDC Sheet
Range("A1").Select
'Select Range A1 on Input Sheet
Sheets("Input").Select
Range("A1").Select
End Sub
Need a quick fix for this macro.
It was working & has quit. I commented out the original code & tried the "lastrow". Obviously, I have screwed up how it should be - and my VB skills are bad @ best...
Any help would be greatly appreciated!
Thank you!
Dim lastrow As Long
lastrow = Range("Y65000").End(xlUp).
'Copy formulas
Sheets("DDC Checklist").Select
Range("Y7:AI7").Select
'Selection.AutoFill Destination:=Range("Y7:AI5
Selection.AutoFill Destination:=Range("Y7:Y" & lastrow)
Range("Y7:AI506").Select
'Select Range A1 on DDC Sheet
Range("A1").Select
'Select Range A1 on Input Sheet
Sheets("Input").Select
Range("A1").Select
End Sub
Could you please post your full code?
ASKER
Sub AddNewLineNewJob()
Range("A4").Select
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromLe ftOrAbove
Selection.RowHeight = 18
Rows("5:5").Select
Selection.Copy
Range("A4").Select
ActiveSheet.Paste
Range("D4:X4").Select
Application.CutCopyMode = False
Selection.ClearContents
'Run macro to copy formulas on DDC sheet
copy_formulae_DDC_Checklis t
Range("D4").Select
End Sub
Sub copy_formulae_DDC_Checklis t()
'This macro updates the formulas on the 'DDC Checklist' sheet when a new row is inserted on the Input sheet.
Dim lastrow As Long
lastrow = Range("Y65000").End(xlUp). Row
'Copy formulas
Sheets("DDC Checklist").Select
Range("Y7:AI7").Select
'Selection.AutoFill Destination:=Range("Y7:AI5 06")
Selection.AutoFill Destination:=Range("Y7:Y" & lastrow)
Range("Y7:AI506").Select
'Select Range A1 on DDC Sheet
Range("A1").Select
'Select Range A1 on Input Sheet
Sheets("Input").Select
Range("A1").Select
End Sub
Range("A4").Select
Selection.EntireRow.Insert
Selection.RowHeight = 18
Rows("5:5").Select
Selection.Copy
Range("A4").Select
ActiveSheet.Paste
Range("D4:X4").Select
Application.CutCopyMode = False
Selection.ClearContents
'Run macro to copy formulas on DDC sheet
copy_formulae_DDC_Checklis
Range("D4").Select
End Sub
Sub copy_formulae_DDC_Checklis
'This macro updates the formulas on the 'DDC Checklist' sheet when a new row is inserted on the Input sheet.
Dim lastrow As Long
lastrow = Range("Y65000").End(xlUp).
'Copy formulas
Sheets("DDC Checklist").Select
Range("Y7:AI7").Select
'Selection.AutoFill Destination:=Range("Y7:AI5
Selection.AutoFill Destination:=Range("Y7:Y" & lastrow)
Range("Y7:AI506").Select
'Select Range A1 on DDC Sheet
Range("A1").Select
'Select Range A1 on Input Sheet
Sheets("Input").Select
Range("A1").Select
End Sub
Try below:
Sub AutoFill()
Dim Ws As Worksheet
Dim lastRow As Long
Set Ws = Worksheets("DDC Checklist")
lastRow = Ws.Range("Y" & Rows.Count).End(xlUp).Row
Ws.Range("Y7").AutoFill Destination:=Ws.Range("Y7:AI" & lastRow)
End Sub
ASKER
Same error...
Are you running my code separately or you are calling from your original code?
Paste above code in your module and run macro AutoFill
ASKER
I called it from the new line macro. And I added the indented line...
Sub AutoFill()
Dim Ws As Worksheet
Dim lastRow As Long
Set Ws = Worksheets("DDC Checklist")
lastRow = Ws.Range("Y" & Rows.Count).End(xlUp).Row
Ws.Range("Y7:AI7").Select
Ws.Range("Y7").AutoFill Destination:=Ws.Range("Y7: AI" & lastRow)
End Sub
Sub AutoFill()
Dim Ws As Worksheet
Dim lastRow As Long
Set Ws = Worksheets("DDC Checklist")
lastRow = Ws.Range("Y" & Rows.Count).End(xlUp).Row
Ws.Range("Y7:AI7").Select
Ws.Range("Y7").AutoFill Destination:=Ws.Range("Y7:
End Sub
Try below:
Sub AutoFill()
Dim Ws As Worksheet
Dim lastRow As Long
Set Ws = Worksheets("DDC Checklist")
lastRow = Ws.Range("Y" & Rows.Count).End(xlUp).Row
Ws.Range("Y7:AI7").AutoFill Destination:=Ws.Range("Y7:AI" & lastRow)
End Sub
ASKER
It doesn't do anything w/out the select.
Have you tried with select?
ASKER
I will. Have to run to a meeting
You try without Select
ASKER
It was a KB that caused the issue
What is KB?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, problem was not from my side, I did gave you solution.
Please assign points reasonably.
Please assign points reasonably.
ASKER
I wasn't trying to not give you points. What I was trying to do was alert others of a possible issue that was not code related. i don't need the points...