Results 1 to 4 of 4

Help with an autofill macro

This is a discussion on Help with an autofill macro within the Excel Questions forums, part of the Question Forums category; Hi All, I have a little problem which I hope someone can help me with. I use the following formula ...

  1. #1
    Board Regular
    Join Date
    Dec 2002
    Posts
    97

    Default

    Hi All,

    I have a little problem which I hope someone can help me with.

    I use the following formula to work out how long a list is (it's never the same number of rows):

    ActiveSheet.UsedRange.Select
    irows = Selection.Rows.Count

    I then put in a couple of formulas in the columns next to it which works fine.

    I then try to autofill using the following code:

    Range("C3:E3").Select
    Selection.AutoFill Destination:=Range("C3:E(irows)"), Type:=xlFillDefault
    Range("C3:E(irows)").Select

    I obviously have the wrong syntax, as the macro stops. If I replace the (irows) with the actual row number it works fine.

    Can someone please put me straight?

    Many thanks,

    Mark


  2. #2
    New Member
    Join Date
    Jan 2003
    Posts
    13

    Default

    Hi

    Have you tried using this method:

    Range("G1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(0, 3).Select
    ActiveCell.FormulaR1C1 = "=(RC[-1]-RC[-7])/RC[-1]"
    Selection.Copy
    Range(Selection, Selection.End(xlUp)).Select
    ActiveSheet.Paste

    Subtitute for your own cell references

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339

    Default

    Your syntax for Range("C3:E(irows)") should be-

    Range("C3:E" & irows)


  4. #4
    Board Regular
    Join Date
    Dec 2002
    Posts
    97

    Default

    Many thanks you two, worked great.

    Mark

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com