+ Reply to Thread
Results 1 to 4 of 4

Multiplying by 100 each cell in input range

  1. #1
    Registered User
    Join Date
    03-17-2014
    Location
    London, UK
    MS-Off Ver
    Excel 2010
    Posts
    26

    Multiplying by 100 each cell in input range

    EDIT: original post asked about adding values. Correct question regards multiplication.

    Hello everyone

    Here's a bit of VBA I found online to calculate a weighted median.

    Please Login or Register  to view this content.
    The code works nicely, except in cases where the cells in WeightRange are between 0 and 1. So it works fine if the cells in WeightRange are 1.0 and above, but the function returns a Value error if they WeightRange has anything like 0.6, 0.3, etc.

    Is there any way of multiplying 100 for each cell in WeightRange while the function runs? I have tried dropping in

    Please Login or Register  to view this content.
    but it doesn't seem to do the trick (then again, I don't know VBA). Seems like something that ought to be simple enough.

    Unfortunately, adding a helper column is not an option, as I have hundreds of these weight ranges....

    Thanks in advance!
    Last edited by lucazzo; 02-17-2017 at 12:51 PM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Adding 100 to each cell in input range

    There are few reasons why the code could error.
    What type of data the code is supposed to return?

    ReDim MedianArray(1 To ArrayLength)
    will fail if the range added is a fraction- you can not loop through a fraction- it got to be an integer.
    The same could be said if the range sum is negative.
    You have not declared many variables. Are they long or double?

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Adding 100 to each cell in input range

    Hi,

    I think you only need a couple of small additions
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    03-17-2014
    Location
    London, UK
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Adding 100 to each cell in input range

    Xlnitwit: PERFECT. That did it. I can confirm it works for all cases. Thank you!

+ 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. Adding date on input in cell
    By Megashira in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2014, 01:54 AM
  2. Replies: 3
    Last Post: 03-06-2013, 05:47 PM
  3. [SOLVED] Adding a range of numbers based on a numerical input
    By merlyn45 in forum Excel General
    Replies: 6
    Last Post: 06-21-2012, 04:43 PM
  4. [SOLVED] Adding color to a cell based on input value
    By cadamhill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2012, 10:15 AM
  5. Adding a Calendar for quick cell input
    By ImagineParidise in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2012, 03:23 AM
  6. Adding input box number to range of cells values
    By Jessica in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2006, 02:10 PM
  7. Problem adding input to cell
    By PghPatti in forum Excel General
    Replies: 6
    Last Post: 06-30-2005, 08:05 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