+ Reply to Thread
Results 1 to 7 of 7

Multiply a whole row of constants by a constant if an "X" appears in column B

  1. #1
    Registered User
    Join Date
    11-06-2015
    Location
    San Diego
    MS-Off Ver
    2013
    Posts
    82

    Multiply a whole row of constants by a constant if an "X" appears in column B

    Hi Gys,
    So I have asked this question here three times and still no working reply. Hoping someone can help me this time. So I am trying to create a macro which will multiply all all the constants in any given row if there is a "X" in the correspong B column of that row. I have a macro which will work for 1 sheet however this has to work for many sheets and this entire problem is getting really frustrating. I will put the code please help me if you can.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Multiply a whole row of constants by a constant if an "X" appears in column B

    You might get more help if you posted a sample workbook with some typical data and indicate what you would expect to get from running the macro.

    regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Multiply a whole row of constants by a constant if an "X" appears in column B

    As it is code like this will only apply to the active sheet.
    Please Login or Register  to view this content.
    PS Why do you have loops for setting the value of one cell?


    Which sheets should the code work for?
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Multiply a whole row of constants by a constant if an "X" appears in column B

    Can't you just change Range("C" & i & ":F" & i) to Range("C" & i & ":F" & i).Cells.Value = Range("C" & i & ":F" & i).Cells.Value*coef ?

    I'm not sure why you're using the Evaluate function, but if you need some kind of IsNumeric test, that could be incorporated as well.

    As suggested, I'd recommend posting a sample sheet with a worksheet that contains raw data (or a subset of it) and a worksheet that contains your desired results because even if the change made above works, it's inefficient.
    Last edited by joe31623; 02-09-2016 at 03:04 PM.
    <---If my answer helped, please click *

  5. #5
    Registered User
    Join Date
    11-06-2015
    Location
    San Diego
    MS-Off Ver
    2013
    Posts
    82

    Re: Multiply a whole row of constants by a constant if an "X" appears in column B

    Hi,
    Okay good idea. Attached is a toned down idea of what I am trying to do. If cell I2 in the config sheet equals "Euro" then all the cells rows throughout the work book with an "x" in column B should be multiplied by a constant lets call the constant cell I3 of the config sheet.
    Thank you so much,
    God Bless
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-06-2015
    Location
    San Diego
    MS-Off Ver
    2013
    Posts
    82

    Re: Multiply a whole row of constants by a constant if an "X" appears in column B

    HI guys,
    Thank you for the reply. First the loops exist because this was meant to convert currencies of selected rows. I will eventually take the correct code and apply multiple IF statements to it so it could work with multiple currencies the names of the currencies will all be inputed in to config cell I2. the coefificients for each currency will be different and will exist on the currency sheet. Sorry that this is confusing. Thank you all so much,
    God Bless.

  7. #7
    Registered User
    Join Date
    11-06-2015
    Location
    San Diego
    MS-Off Ver
    2013
    Posts
    82

    Re: Multiply a whole row of constants by a constant if an "X" appears in column B

    Hi guys,

    attached is a better version if you still are not getting what i amt trying to do sorry for the confusion. Hopefully this helps. So basically if config(I2) equals "Euro" then all the rows that have a x in column B should be multiplied by cell A1 on the currency sheet. The rows being multiplied should multiply from row C until say row K. the same condition should apply for if config(I2) equals say Peso. it should multiply all rows with an "x" on column B by cell B1 on the currency page.
    If I cam provide anymore clarification please ask.
    God Bless.
    Attached Files Attached Files

+ 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. [SOLVED] "ByRef:mismatch" and "Constant Expression Required" Errors
    By Mishil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-10-2015, 06:47 PM
  2. [SOLVED] find a total of times a word appears across all the sheets in column "C"
    By NickB79 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2013, 10:28 AM
  3. [SOLVED] Need to cut row and Paste on another worksheet if "Deleted" appears in column
    By calberts in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-13-2013, 05:32 PM
  4. If any in list equal "value" then multiply Column B * C
    By derekjames in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-18-2012, 04:19 AM
  5. Replies: 5
    Last Post: 07-05-2012, 04:04 PM
  6. Replies: 8
    Last Post: 07-05-2012, 03:07 PM
  7. Macro to CUT & Paste a row to another sheet if "Active" appears in Column J
    By Fferjay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2011, 12:25 PM

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