Excel VBA “Autofill Method of Range Class Failed”

后端 未结 4 883
醉梦人生
醉梦人生 2020-12-16 22:28

The following VBA code (Excel 2007) is failing with Error 1004, \"Autofill Method of Range Class Failed.\". Can anyone tell me how to fix it?

Dim src As Ran         


        
4条回答
  •  萌比男神i
    2020-12-16 23:09

    Not sure if this helps anyone, but I needed something similar. Selecting the cells as destination works;

    dim rowcount as integer
    Sheets("IssueTemplate").Select ' Whatever your sheet is
    rowcount = 0
    rowcount = Application.CountA(Range("A:A"))'get end range
    Cells(4, 3).Select 'select the start cell
    'autofill to rowcount
    Selection.AutoFill Destination:=Range("C4:C" & rowcount), Type:=xlFillDefault 
    

    in my example I had to auto-generate a list of folder names from OA100 to OA###?, and this worked fine.

提交回复
热议问题