Consulting

Results 1 to 3 of 3

Thread: Autofill or something else to multiply a formula

  1. #1
    VBAX Regular
    Joined
    Oct 2012
    Location
    Iasi, Romania
    Posts
    18
    Location

    Autofill or something else to multiply a formula

    Hello,

    I am facing a problem and I can't find a solution.
    I have a range with some "SUM" formulas in cells...let's say, for example, that in cell H1 I have the formula A1+C1+E1, in cell H2 I have A2+C2+E2 and so on until H10=A10+C10+E10.
    Now, if I want to autofill the formula in cells J1:J10, the formulas will be J1=C1+E1+G1 ..... J10=C10+E10+G10. Practically, it jumps 2 columns - from A to C, from C to E and from E to G - and this is quite normal, but if I want to autofill the formula 2 columns to the right but in the way of jumping only one column in SUM? This means that the sums should be J1=B1+D1+F1 ... J10=B10+D10+F10.

    Hope I was clear and I thank you for your kind support,
    Adrian

  2. #2
    VBAX Regular
    Joined
    Oct 2012
    Location
    Iasi, Romania
    Posts
    18
    Location
    I attached also a sample file.
    Thank you!
    Attached Files Attached Files

  3. #3
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    You could copy H1 to I1, drag it to J1 then autofill down, or try the following which does exactly that by VBA.

    [vba]Sub FormulaEntry()
    Dim LR As Long
    Dim Temp As String
    LR = Range("H" & Rows.Count).End(xlUp).Row
    Temp = Range("I1").Formula
    Range("I1").Formula = Range("H1").Formula
    Range("J1").Resize(LR, 1).FormulaR1C1 = Range("I1").FormulaR1C1
    Range("I1").Formula = Temp
    End Sub[/vba]
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

Posting Permissions

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