+ Reply to Thread
Results 1 to 9 of 9

Loop through column and find value on a different sheet, then apply formula to entire row

  1. #1
    Registered User
    Join Date
    03-08-2021
    Location
    Spain
    MS-Off Ver
    10
    Posts
    4

    Post Loop through column and find value on a different sheet, then apply formula to entire row

    Sheet "Forecast" has rows with different categories, and also rows that include CURRENCY names such as "US Dollar", "Swiss Franc", ... In these rows there are at some cells amounts in number (eg 100).

    I n sheet "Currency" I have a table with rows of all possible curreny names (eg US Dollar) and to the right there is the value it needs to be multiplied by so it shows the euro amount.

    SO the macro I am trying to build should:
    go through each cell of the column in "Forecast" sheet that includes the currency names, if the cell matches a name of the currencies from "Currencies" sheet table, then it should get all values of the row where that cell is and if they are numbers multiply them by the value to the right of the matched currency.

    It is my first time with VBA so this is my first (completely wrong) code for it.:

    Please Login or Register  to view this content.

    Thank you everyone for the help
    Attached Files Attached Files
    Last edited by delacomarca; 03-09-2021 at 03:29 PM.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,673

    Re: Need help for complex Macro

    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    03-08-2021
    Location
    Spain
    MS-Off Ver
    10
    Posts
    4

    Re: Need help for complex Macro

    Thank you. I uploaded the file at the original post.

    The goal is that when you click convert the numbers in the rows that include US dollar or Swiss franc... are multiplied by (e.g 100 usd * 0,8)

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,673

    Re: Need help for complex Macro

    For clarification let's use a few examples.

    When you loop through column C of the Forecast sheet , the second currency is US Dollar in cell C19. In the Currency sheet, the number to the right of US Dollar is 1.18721. You want to multiply all the values in row 19 by 1.18721. Is this correct?

    When you loop through column C of the Forecast sheet , the first currency is EUR in cell C18. In the Currency sheet, the number to the right of EUR is 1.00. I would assume that you would not need to multiply the values in row 18 by 1.00 because the result would not change. Is this correct?

    You then want to repeat this process for all the currencies in column C. Is this correct?

    If I didn't understand properly, please explain what you want to do in the same manner as I explained above.

    When would you use the values in column D of the Currency sheet?
    Last edited by Mumps1; 03-09-2021 at 02:06 PM.

  5. #5
    Registered User
    Join Date
    03-08-2021
    Location
    Spain
    MS-Off Ver
    10
    Posts
    4

    Re: Need help for complex Macro

    Sorry, in the first post I said the one to the right but it actually meant two to the right. SO everything you said is right, only that I need to multiply with the second value, so in your example US Dollar of cell 19 means all numbers in that row get multiplied by 0.842311 instead of 1.18721

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    2007, Office 365
    Posts
    11,937

    Re: Need help for complex Macro

    Hello delacomarca. Welcome to the forum.

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Dave

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,673

    Re: Loop through column and find value on a different sheet, then apply formula to entire

    Assign this macro to the "Convert to EUR" button and click it.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-08-2021
    Location
    Spain
    MS-Off Ver
    10
    Posts
    4

    Re: Loop through column and find value on a different sheet, then apply formula to entire

    Thanks so much Mumps1!, The code works perfectly!
    Last edited by delacomarca; 03-10-2021 at 05:00 AM.

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,673

    Re: Loop through column and find value on a different sheet, then apply formula to entire

    You are very welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help Building a complex Macro
    By shane3200 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-04-2017, 12:00 PM
  2. Slightly complex macro
    By Apophis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-21-2014, 09:37 AM
  3. Complex Macro Help
    By MrDuck1984 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2011, 06:37 PM
  4. Complex Macro Help
    By rmiranda1824 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2011, 11:17 AM
  5. complex macro
    By sukhi_01 in forum Excel General
    Replies: 2
    Last Post: 05-16-2008, 06:17 AM
  6. complex macro
    By sukhi_01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2008, 12:06 PM
  7. Complex macro/function.
    By deewhyoh in forum Excel General
    Replies: 6
    Last Post: 03-27-2007, 06:23 AM

Tags for this Thread

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