+ Reply to Thread
Results 1 to 7 of 7

Divide a range by another range

  1. #1
    Forum Contributor
    Join Date
    10-07-2013
    Location
    Wilts, England
    MS-Off Ver
    Excel 2013
    Posts
    100

    Divide a range by another range

    Hi all, really stumped here. Have searched all over and seemed to find an answer but can't get it to work for me, so anyhelp would be great.
    I have a script which loops through a column in an excel workbook and for each filled cell in turn checks the value and depending on its value calls a sub which adds bookmarks to a word template.

    What I'm trying to do is if the cell value of the found cell in "I" is >1 then find a cell in column "c" of the corrosponding row number. Then divide the value of cell "C?" by the value "I?".
    Both "c" & "i" are stored as ranges as they need to be for the bookmark code.
    Is what I'm trying to do possible?
    I have tried converting the ranges to Integers, Long, Short, and tried rounding them, Int, Value. Cell..... but always comes back "Type Mismatch".

    So the top one is what I'd like to happen.

    Please Login or Register  to view this content.
    Have tried adding the value of "I" as a set value of x but that doesn't work either. However my bookmark code does work, so it is finding fCell.

    Please Login or Register  to view this content.
    Any help would be great
    Last edited by beenbee; 03-05-2014 at 07:52 AM. Reason: more info

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Divide a range by another range

    I'm not sure I follow what you're asking, but I think you just have defined fCell (cell n column C) incorrectly.

    Try this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    10-07-2013
    Location
    Wilts, England
    MS-Off Ver
    Excel 2013
    Posts
    100

    Re: Divide a range by another range

    Thank you so much, thats great! The only thing is it displays the new value in "Range("C" & aCell.Row)". Is there a way for that not to happen and it just be used within the script?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Divide a range by another range

    Quote Originally Posted by beenbee View Post
    Thank you so much, thats great! The only thing is it displays the new value in "Range("C" & aCell.Row)". Is there a way for that not to happen and it just be used within the script?
    This restores the fCell value after calling wbookmark2

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-07-2013
    Location
    Wilts, England
    MS-Off Ver
    Excel 2013
    Posts
    100

    Re: Divide a range by another range

    Thank you, should have seen that mysefl.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Divide a range by another range

    You're welcome.

    Also note, this procedure is not a Function. It's just a Sub procedure. Functions return a value to the caller.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-07-2013
    Location
    Wilts, England
    MS-Off Ver
    Excel 2013
    Posts
    100

    Re: Divide a range by another range

    Thank you again! Haven't been writing VBA very long.

+ 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] Divide range by range VBA
    By vizzkid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2013, 12:32 PM
  2. Problem using sumif to divide by a range
    By Flobiwan in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-26-2012, 04:20 PM
  3. Replies: 5
    Last Post: 07-16-2010, 01:45 PM
  4. Divide a range by 1000
    By 1heng in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-29-2007, 01:21 PM
  5. Sum Range + Divide by another range
    By bunny81255 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 09-08-2007, 06:28 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