+ Reply to Thread
Results 1 to 6 of 6

VBA to multiply any/all numeric cells in usedrange by a user-prompted value?

  1. #1
    Registered User
    Join Date
    03-03-2009
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    53

    VBA to multiply any/all numeric cells in usedrange by a user-prompted value?

    I'm trying to think of the best way to create a VBA macro that does the following...

    1. Prompts user for a value.
    2. Finds any/all cells in "UsedRange" that are NUMERIC (there are text cells it will need to ignore)
    3. Multiply the cell value by the user-prompted value.
    4. New value REPLACES old value in cell.

    I know enough about the basics that I could probably trial-error my way through this in a couple hours.
    However, I'm sure there must be an "easy" way.

    My main concern is that I don't know if I can figure out how to detect ONLY the numeric cells.
    Also, will I need a "FOR EACH" loop, or a "WITH" loop?

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,889

    Re: VBA to multiply any/all numeric cells in usedrange by a user-prompted value?

    I usually wouldn't recommend this. As date is stored as number in Excel and other computing system.

    If your date formatting is consistent, you could check for specific NumberFormat of the cell.

    But in general, it's faster to just put value in some out of way cell, copy. Right click. S, S, V, M. To multiply range by specific value.

    If you must... something like below, assuming "m/d/yyyy" date format.
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    03-03-2009
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: VBA to multiply any/all numeric cells in usedrange by a user-prompted value?

    Thanks! I will test it out, ASAP.
    Just an FYI, there are no date values in my data, only text (or general) and numeric.

  4. #4
    Registered User
    Join Date
    03-03-2009
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: VBA to multiply any/all numeric cells in usedrange by a user-prompted value?

    Quote Originally Posted by CK76 View Post
    Please Login or Register  to view this content.
    This worked great! I added
    Please Login or Register  to view this content.
    so that it would ignore empty cells.

    How do I mark this question as SOLVED, or do the admins do it?

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,889

    Re: VBA to multiply any/all numeric cells in usedrange by a user-prompted value?

    Thread tools at top of your initial post. There should be option to set it to solved.

  6. #6
    Registered User
    Join Date
    03-03-2009
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: VBA to multiply any/all numeric cells in usedrange by a user-prompted value?

    Got it, THANKS!

+ 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] Check for empty cells with in usedrange then tell user which cell is empty.
    By kjbrigham in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2021, 02:27 AM
  2. [SOLVED] Increment cell value beginning from user prompted input
    By ssmith001 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-23-2018, 11:37 AM
  3. How to insure a user is prompted to input a date as format MM/DD/YYYY
    By gshowman1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2018, 10:58 PM
  4. [SOLVED] User prompted sheet name stored with quotations. I need them gone to be inputted into sub
    By grazian2 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-05-2013, 11:42 AM
  5. Excel Export to OLE Object with user prompted SaveAs HELP
    By leemanx in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-24-2013, 12:31 PM
  6. VBA to prompted user for employee number.
    By Absent in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-27-2012, 05:53 PM
  7. [SOLVED] not being prompted that user has file open
    By maryj in forum Excel General
    Replies: 0
    Last Post: 12-15-2005, 11:15 AM

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