+ Reply to Thread
Results 1 to 10 of 10

If Column A contains month name, multiply a range by a specific number

  1. #1
    Registered User
    Join Date
    05-01-2023
    Location
    Singapore
    MS-Off Ver
    (Version 2302 Build 16.0.16130.20378) 64-bit
    Posts
    66

    If Column A contains month name, multiply a range by a specific number

    Hi experts! I'm wondering if this can be done in VBA.

    Column A contains the months of a year. Could be in the format of words like "January, February, etc" or in date form like "31/01/23, 28/02/23, etc".

    Is it possible to use an If Loop to:
    If Cell in Column A contains "January" or "31/01/23", multiply columns B:G in THAT ROW by 1
    If Cell in Column A contains "February" or "28/02/23", multiply B:G in THAT ROW by 2
    If Cell in Column A contains "March" or "31/03/23", multiply B:G in THAT ROW by 3
    Etc all the way to December where u multiply B:G in that row by 12

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: If Column A contains month name, multiply a range by a specific number

    Try

    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    05-01-2023
    Location
    Singapore
    MS-Off Ver
    (Version 2302 Build 16.0.16130.20378) 64-bit
    Posts
    66

    Re: If Column A contains month name, multiply a range by a specific number

    a(i, c) = a(i, c) * mult

    This line produces 'Type mismatch' error.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: If Column A contains month name, multiply a range by a specific number

    Well, post a file.
    Attached Files Attached Files

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: If Column A contains month name, multiply a range by a specific number

    If data starts in A1 and row 1 is headers then this should work...

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 07-19-2023 at 11:11 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Registered User
    Join Date
    05-01-2023
    Location
    Singapore
    MS-Off Ver
    (Version 2302 Build 16.0.16130.20378) 64-bit
    Posts
    66

    Re: If Column A contains month name, multiply a range by a specific number

    I uploaded a file to illustrate my example.

    January: Multiply by 12/1 = 12
    February: Multiply 12/2 = 6
    March: Multiply by 12/3 = 4
    April: Multiply by 12/4 = 3
    May: Multiply by 12/5 = 2.4

    Pattern continues until december

    Test.xlsx

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: If Column A contains month name, multiply a range by a specific number

    not what you originally asked!

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-01-2023
    Location
    Singapore
    MS-Off Ver
    (Version 2302 Build 16.0.16130.20378) 64-bit
    Posts
    66

    Re: If Column A contains month name, multiply a range by a specific number

    Thank you!
    Last edited by webcam723; 07-19-2023 at 11:13 PM.

  9. #9
    Registered User
    Join Date
    05-01-2023
    Location
    Singapore
    MS-Off Ver
    (Version 2302 Build 16.0.16130.20378) 64-bit
    Posts
    66

    Re: If Column A contains month name, multiply a range by a specific number

    Currently row 2 stays the same and does not multiply. what is the issue here?

    Edit: found the error, just changed for i = 1 in line 5
    Last edited by webcam723; 07-19-2023 at 11:23 PM.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: If Column A contains month name, multiply a range by a specific number

    My correction based on your sample file...
    Please Login or Register  to view this content.

+ 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. PowerPivot Multiply value by number of days of month.
    By saudi_red_neck in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-08-2022, 08:26 AM
  2. Counting specific number in a column in a certain month
    By Michael Santuile in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-15-2021, 01:54 AM
  3. [SOLVED] How can I multiply all values by a factor in the used range of a specific column
    By notitia in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2017, 06:46 AM
  4. [SOLVED] Find specific values and multiply them by a number in their column
    By Thomas92W in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-29-2014, 01:22 PM
  5. Replies: 2
    Last Post: 12-17-2013, 06:30 AM
  6. Counting the Number of Workdays Specific to a Month in Larger Range
    By dmbatcofc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-11-2013, 12:28 PM
  7. [SOLVED] Multiply by different number every month
    By Granny in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-29-2012, 02:27 PM

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