SOLVED: VBA Autofill problem

  • This is part of code that I am trying to use, but fails at the last line ("AutoFill method of range class failed").


    Code
    Range("B2").Select
        With ActiveCell
            .FormulaR1C1 = "=PROPER(TRIM(RC[-1]))"
        End With
        Range("B2").AutoFill Destination:=Range("B2:B" & Range("B65536").End(xlUp).Row)


    Is there something I am missing? (Obviously, but not sure).


    Any help would be appreciated.


    Software: OpenOffice 3.0/NeoOffice 3.0 on Mac OS X 10.5.6
    Humanware: Older than dirt


    Old, slow, and confused - but at least I'm inconsistent!


    Rich
    (retired Excel 2003 user, 3.28.2008)

  • Problem


    Looks like to me that your not specifying the worksheet for the range.


    for example:


    Worksheets("MyWorksheet").Activate
    Range("B2").Select
    With ActiveCell
    .FormulaR1C1 = "=PROPER(TRIM(RC[-1]))"
    End With
    Range("B2").AutoFill Destination:=Worksheet("MySheet").Range("B2:B" & Range("B65536").End(xlUp).Row)

  • Thanks. Everything is taking place on the same worksheet. However, I tried your suggestion and included the worksheets("Test").Range... And it still registers the same error.


    Software: OpenOffice 3.0/NeoOffice 3.0 on Mac OS X 10.5.6
    Humanware: Older than dirt


    Old, slow, and confused - but at least I'm inconsistent!


    Rich
    (retired Excel 2003 user, 3.28.2008)

  • Okay, it was doing everything I told it to do, but I wasn't telling it correctly!


    The range needed to be based on column A, since Col B only had data in B2. Therefore my line needed to be:

    Code
    Range("B2").AutoFill Destination:=Range("B2:B" & [b]Range("A65536")[/b].End(xlUp).Row)


    Software: OpenOffice 3.0/NeoOffice 3.0 on Mac OS X 10.5.6
    Humanware: Older than dirt


    Old, slow, and confused - but at least I'm inconsistent!


    Rich
    (retired Excel 2003 user, 3.28.2008)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!