+ Reply to Thread
Results 1 to 11 of 11

Have a cell automatically multiplied by a value and be able to dynamically specify cell

  1. #1
    Registered User
    Join Date
    02-09-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    10

    Have a cell automatically multiplied by a value and be able to dynamically specify cell

    I want to be able to enter a value into a cell and have it automatically multiply by a set value and overwrite the original entry with the result so making it all happen within one cell.
    -This question has been asked already.

    But what I want is that I should be able to specify for which cells this applies to, dynamically, not hard coded.
    So that I can specify a column in a sheet in which I would add cell references and that any cell references (for any sheet) that is in that column would have the VBA routine applied to it.

    Thanks

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    https://msdn.microsoft.com/en-us/lib...or=-2147217396

    Did you have a look here?
    I don't know which columns etc you want this to happen to but you should be able to figure out how to from above's site

  3. #3
    Registered User
    Join Date
    02-09-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    10

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    I know the actual code to write:
    Please Login or Register  to view this content.
    What I don't know how to write is the IF logic.
    I don't want 'Intersect' because I don't want to hardcode the cells I want as a target

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    Like this?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-09-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    10

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    No,
    I want to put references to random cells in a column (or a range) that should be for-looped and only if target = 'that reference' then Target.Value = Target.Value * 1000

    Also can this routine be written for the whole workbook or can it only be per worksheet?

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    I am afraid that I am lost.
    In your first code you mention that you don't want the ranges (cells) hard coded.
    How do you want the code to know which cells are the random cells ("that reference") in a column, as you mention in Post #5?
    I am not all that familiar with Worksheet_Change events but I would think that each sheet will need its own code.

  7. #7
    Registered User
    Join Date
    02-09-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    10

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    See sample file.
    I would like to specify on the Lookup sheet in cells A1:A20 which cells should "automatically multiply by a set value".
    In the sample I have specified 4 cells. see sheet Lookup cells A1:A4. So I would have the code loop through cells A1:A20 and any cell that has a value in it, have that cell "automatically multiply by a set value".
    Sorry for the confused question.
    Am I clear yet?
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    Try this.
    Put in in a Sheet Module, save the file, and try it.

    Please Login or Register  to view this content.
    Last edited by jolivanes; 09-20-2015 at 10:47 PM. Reason: Changed code

  9. #9
    Registered User
    Join Date
    02-09-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    10

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    It didn't work....
    If I add it to the code for the Microsoft Excel Object for the first sheet it will throw a runtime error of '13', type mismatch -the 'arr' variable is empty.
    If I switch the code from C1:C to A1:A I still get the same error but in debug the 'arr' variable is: "Data!B1" which is the first value.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    It works for me.
    See attached.
    BTW, did you use the latest code in post #8?

    Let us know if it works.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-09-2015
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    10

    Re: Have a cell automatically multiplied by a value and be able to dynamically specify ce

    Thanks that worked, now I see how you changed what I had in the lookup sheet.
    I modified your code so that I can have the lookup sheet handle multiple sheets (I would have to add the code to any sheet I want it to work for)
    The only error I am still getting is if I add an invalid entry to Column C it chokes. Instead of something like B8, I add hello.
    I am not sure why, you did add " On Error Resume Next".
    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. Replies: 9
    Last Post: 05-28-2014, 10:00 AM
  2. Replies: 1
    Last Post: 09-18-2013, 01:58 PM
  3. Replies: 2
    Last Post: 02-08-2013, 04:08 PM
  4. Dynamically moving cell contents to cell comments within a column
    By Bouje in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2013, 11:21 PM
  5. Replies: 0
    Last Post: 06-29-2011, 01:10 PM
  6. Replies: 1
    Last Post: 12-07-2008, 03:41 PM
  7. same cell multiplied by set value
    By lynk787 in forum Excel General
    Replies: 1
    Last Post: 01-23-2005, 03:06 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