+ Reply to Thread
Results 1 to 3 of 3

VBA divide by number of cells used per row

  1. #1
    Registered User
    Join Date
    04-29-2016
    Location
    Amsterdam
    MS-Off Ver
    2010
    Posts
    1

    VBA divide by number of cells used per row

    Hi everyone,

    I really hope you can help me with this problem.

    I have written a code where I put every row of data into deciles (6 deciles) and then take averages of these cells (plus 1 month so 1 row below).
    The code does that fine. Only I get the average of all the cells that have the same decile.

    At first I thought that excel gave the same number of cells for deciles. So 48 columns = 8 columns per decile (I have 6 deciles)

    Only i saw that that is not true. Some deciles have more and some less.
    So my question is:
    How can I divide by the number of cells used and this has to be adjusted for every row?

    If (DECILE_RANK = 1) Then
    d11m = d11m + Application.Average(DataSheet.Range(Letter & CStr(i) & ":" & Letter & CStr(i + 1)))
    ''d11m= decile 1+ 1 month''

    DecileSheet.Range("B" + CStr(i)).Value = (d11m / HERE ? what should i divide it by?)

    I was thinking of a countif function. But i do not know how to write that to adjust for every row.

    Thanks in advance

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA divide by number of cells used per row

    Very difficult to comment without seeing the workbook. Upload it and manually add the results you expect. Don't forget to mention which are the result cells and the calculations you've used to get the results.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA divide by number of cells used per row

    Not sure if this helps. Test it and see.

    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. How to divide a number randomly between cells
    By VelvetRain in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 11-24-2020, 05:38 AM
  2. [SOLVED] Divide a number into multiple cells
    By rhon101 in forum Excel General
    Replies: 6
    Last Post: 03-03-2020, 08:20 PM
  3. Replies: 5
    Last Post: 09-14-2015, 05:11 AM
  4. Creating a Formula to Divide Cells by the Row Number
    By RobertoCutch in forum Excel General
    Replies: 2
    Last Post: 04-17-2015, 10:35 PM
  5. [SOLVED] Divide a number into multiple cells
    By beitzy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-13-2013, 07:41 AM
  6. Divide only with number of cells with value>0
    By primaxx in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-27-2009, 03:39 AM
  7. how do you divide the average of a number into 3 different cells.
    By Shaun in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-25-2006, 05:15 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