+ Reply to Thread
Results 1 to 15 of 15

If and Then Formula/Code to multiply with a Designated Cell

  1. #1
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Lightbulb If and Then Formula/Code to multiply with a Designated Cell

    Hi Everyone,

    I need a VBA code for the data in the attached sheet.

    The logic goes as this.

    If the filter is Full_Dispute or Partial_Dispute (Column T) and the Currency is USD (Column W), then mutiply Absolute Amount (Column U) with E2 (1)

    If the filter is Full_Dispute or Partial_Dispute (Column T) and the Currency is EUR (Column W), then Divide Divide Amount (Column U) with E3 (0.79)

    The result should be updated in Column C

    Appreciate your assistance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Hi, I copied your code into VBA and run the macro. but i dont see any change in my data.

    Can you also help me understand your code since im a novice in VBA codes.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If and Then Formula/Code to multiply with a Designated Cell

    I first copied the information you had in Columns A, B, and D in your sample data to the Columns you referenced in Post 1. The code will look at each cell in Column T if cell = "FULL_DISPUTE" or "PARTIAL_DISPUTE" it should perform the calculations based on the Values in E2, E3 and USD, EUR. You may have been waiting for it too operate on the sample data from Columns A, B, and D. Be advised that I did change your data too confirm too the requirements you set forth in Post 1.

  5. #5
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Hi John - That worked correct when i move the data to column T. Just wanted to understand the code.
    What does this mean.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: If and Then Formula/Code to multiply with a Designated Cell

    I have understood the code more or less. Wanted to understand how can i change the result of the macro from column C to anywhere else.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Quote Originally Posted by aaron.mendes View Post
    Hi John - That worked correct when i move the data to column T. Just wanted to understand the code.
    What does this mean.

    Please Login or Register  to view this content.

    That statement means that if the cell in the next column to the right is not null then select the value of the cell thats three Columns to the right "USD", "EUR".

    The reason I used that check was because when I was using ABS value it would error out if the cell in Column U was null.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If and Then Formula/Code to multiply with a Designated Cell

    This line tells it too place the results in Column C

    cell.Offset(, -17)

    If offsets backwards from Column T. For instance if you wanted the results to go into Column A then

    cell.Offset(, -19)

    Column B

    cell.Offset(, -18)

  9. #9
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Is it possible for a msg box to pop up instead of placing my content on E2 or E3?
    the result would be that my final data would multiply with the number I input in the msg box

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Quote Originally Posted by aaron.mendes View Post
    Is it possible for a msg box to pop up instead of placing my content on E2 or E3?
    the result would be that my final data would multiply with the number I input in the msg box

    Please Login or Register  to view this content.
    Maybe:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Thats great.
    since i need to different values for EUR/USD, i tweaked it a little. let me know if this is correct

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Actually I realized that after Post 10. Good catch. Perfect.

  13. #13
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Thanks. this helped me.

    can i convert an amount in a particular column into Absolute value rather than pasting the converted absolute value in another column?
    what code would do that job?

  14. #14
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If and Then Formula/Code to multiply with a Designated Cell

    Same as used in the code, write it as you would in a formula.

    Abs(cell.Offset(, 1))

  15. #15
    Registered User
    Join Date
    07-01-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: If and Then Formula/Code to multiply with a Designated Cell

    If the result of my above Code is in column B (Abs value) and I have an amount in column A which is not an absolute value, what code be be required such that it will first convert column A into an ABS value and then find the difference with column A.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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