+ Reply to Thread
Results 1 to 10 of 10

Macro to Fix Auto-Pattern?

  1. #1
    Registered User
    Join Date
    04-06-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Macro to Fix Auto-Pattern?

    Hi,

    The spreadsheet I'm working on is kinda hard to describe, but I'll try.

    It's a finance calculator of sorts that I need done, and it shows me the total cost of various products. Each of these products require different components, and numbers of components, and also these components all cost different prices. So what I have is the following spreadsheet setup:

    Please Login or Register  to view this content.
    So all I have to do is enter the amount of the component needed and my spreadsheet (this part I've done) multiples the 'Component' by the 'Number Needed.'

    Now the thing is that there are quite a few different products, so in the side I've created a universal price list, that shows the prices of all my products. So to get the price of each product I've further created these columns:

    Please Login or Register  to view this content.
    And what I want to do is make it multiple the Number Needed * Cost of Component and then be able to use the auto formula to go down the page to autofill these values (since I have about 100, so that would take AGES manually).

    So how could I do this? The pseudo code for this patter autofil would be:

    Column AA = R[ROW NUMBER]
    Column AB = S[ROW NUMBER] * AO14
    Column AC = T[ROW NUMBER] * AO15
    Column AD = U[ROW NUMBER] * AO16
    Column AE = V[ROW NUMBER] * AO17
    Column AF = W[ROW NUMBER] * AO18
    Column AG = X[ROW NUMBER] * AO19
    Column AH = Y[ROW NUMBER] * AO20


    And then the pattern as it auto fills would be:
    Column AA = R[ROW NUMBER + 1] * AO14
    Column AB = S[ROW NUMBER + 1] * AO15


    But Excel doesn't put that down as it's auto fill. Instead it decides to do:
    [ROW NUMBER + 1] * AO17

    ALL the way down... which is wrong. How could I fix this?

    Thanks (hope I explained my problem clearly, if not please ask I'll try to clarify
    -Rudey
    Last edited by Rudey; 04-07-2009 at 11:45 PM.

  2. #2
    Registered User
    Join Date
    04-06-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macro to Fix Auto-Pattern?

    Can anybody help?

  3. #3
    Registered User
    Join Date
    04-06-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macro to Fix Auto-Pattern?

    Anybody? I just to need to know the code for

    Column = LETTER[ROW NUMBER + 1]

  4. #4
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to Fix Auto-Pattern?

    I can't understand your explanation.
    I think it would be easier to show what you want in each cell and what Excel is putting into it:

    Example:
    What I want:
    AA14: =R14
    AB14: =S14*AO14

    AA15: =R15
    AB15: =S15*AO15

    What Excel does:
    AA14: =R14*AO17
    AA15: =R15*AO17

  5. #5
    Registered User
    Join Date
    04-06-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macro to Fix Auto-Pattern?

    Hi,

    That's exactly what's happening.

    I want:

    AB4 = S4 * AO14
    AB5 = S5 * AO14
    AB6 = S6 * AO14
    AB7 = S7 * AO14
    AB8 = S8 * AO14
    AB9 = S9 * AO14



    What Excel gives me is:

    AB7 = S7 * AO17
    AB8 = S8 * AO17
    AB9 = S9 * AO17

    I don't know how it managed to get to the AO17 multiplier, because the first part of the formula is right. But yeah, hope that's easier to understand. Because when I fix one, the others will work afterwards because it is all the same pattern.

    Thanks for the reply!

  6. #6
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to Fix Auto-Pattern?

    Ok, how are you doing the autofill? I can't see any reason why Excel is getting it wrong. I can only guess that you're accidentally telling excel to copy the wrong formula.

  7. #7
    Registered User
    Join Date
    04-06-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macro to Fix Auto-Pattern?

    I have got that same formula written into the following:

    AB4 = S4 * AO14
    AB5 = S5 * AO14
    AB6 = S6 * AO14

    Then I highlight them all and drag down 3 more and the output it gives me is:

    AB7 = S7 * AO17
    AB8 = S8 * AO17
    AB9 = S9 * AO17

  8. #8
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to Fix Auto-Pattern?

    Didn't notice before. You want
    AB4 = S4*AO14
    AB5 = S5*AO14 (not AO15)
    AB6 = S6*AO14 (not AO16)

    you should enter:
    AB4 = S4*$AO$14 (or AO$14)
    AB5 = S5*$AO$14 (or AO$14)

    then do your autofill.

  9. #9
    Registered User
    Join Date
    04-06-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macro to Fix Auto-Pattern?

    Wow it works! Can you explain why that works, just so I know and rememebr this for the future?

    Thanks heaps once again!

  10. #10
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro to Fix Auto-Pattern?

    Its Relative vs Absolute addresses. You'll want to read up on it. It's one of most basic strengths in Excel.
    If you look up "Relative Address" in the help file, they can probably explain it better than I can.

    The $ in from of the row # tells Excel you want that specific row (absolute row). Without the $ tells Excel you want the row that is x rows above or below the cell (relative row).
    Works the same for the Columns. Put a $ in front of the Column letter and it refers to a specific column. Without the $, it refers to a column that is x columns to the left or right.



    When you entered the formula into cell AB4: = S4*AO14 you were telling Excel you wanted "the cell 9 columns to the left (S4) * the cell 13 columns to the right and 10 rows down (AO14)".
    So when you pasted into AB7 it put in a formula: "the cell 9 columns to the left (S7) * the cell 13 columns to the right and 10 rows down (AO17)" (result S7*AO17)

    With you entered the formula into cell AB4: = S4*AO$14 you were telling Excel you wanted a formula that refered to "the cell 9 columns to the (S4) * the cell 13 columns to the right and ROW 14".
    So when you pasted into AB7 it put in a formula "the cell 9 columns to the left (S7) * the cell 13 columns to the right and Row 14 (AO$14)" (result S7*AO$14)


    Does that explain things?
    Last edited by foxguy; 04-08-2009 at 10:50 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1