+ Reply to Thread
Results 1 to 9 of 9

Number down column based on criteria of another and add up value

Hybrid View

mikesmoua Number down column based on... 11-18-2015, 12:09 PM
JOHN H. DAVIS Re: Number down column based... 11-18-2015, 12:35 PM
mikesmoua Re: Number down column based... 11-18-2015, 12:46 PM
JOHN H. DAVIS Re: Number down column based... 11-18-2015, 12:50 PM
JOHN H. DAVIS Re: Number down column based... 11-18-2015, 12:48 PM
Glenn Kennedy Re: Number down column based... 11-18-2015, 12:51 PM
mikesmoua Re: Number down column based... 11-18-2015, 01:07 PM
JOHN H. DAVIS Re: Number down column based... 11-18-2015, 01:17 PM
mikesmoua Re: Number down column based... 11-20-2015, 10:37 AM
  1. #1
    Registered User
    Join Date
    11-18-2015
    Location
    Wisconsin, USA
    MS-Off Ver
    2010
    Posts
    4

    Number down column based on criteria of another and add up value

    This is what I have.

    s 2
    s 3
    s 1
    s 7
    s 0
    s 8
    s 8
    f 3
    f 1
    f 5
    f 6
    f 4
    h 0
    h 8
    h 9
    u 6
    u 7
    u 8
    u 10


    This is what I will need.


    1 s 2 29
    1 s 3
    1 s 1
    1 s 7
    1 s 0
    1 s 8
    1 s 8
    2 f 3 19
    2 f 1
    2 f 5
    2 f 6
    2 f 4
    3 h 0 17
    3 h 8
    3 h 9
    4 u 6 31
    4 u 7
    4 u 8
    4 u 10
    Last edited by mikesmoua; 11-18-2015 at 12:12 PM.

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

    Re: Number down column based on criteria of another and add up value

    Maybe:

    Sub mikesmoua()
    Dim i As Long
    With Application
        .ScreenUpdating = False
        .Calculation = xlManual
    End With
    For i = Range("A" & Rows.Count).End(3).row To 1 Step -1
        If Cells(i, "A") <> Cells(i + 1, "A") Then Rows(i + 1).Insert
    Next i
    For Each numrange In Columns(2).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            With numrange.Offset(numrange.Count, 1).Resize(1, 1)
                .Formula = "=SUM(" & sumaddr & ")"
                .Value = .Value
                .Cut numrange.Cells(1, 1).Offset(, 1)
            End With
            c = numrange.Count
    Next numrange
    Range("A2:A" & Range("A" & Rows.Count).End(3).row).SpecialCells(4).EntireRow.Delete
    With Application
        .Calculation = xlAutomatic
        .ScreenUpdating = True
    End With
    End Sub

  3. #3
    Registered User
    Join Date
    11-18-2015
    Location
    Wisconsin, USA
    MS-Off Ver
    2010
    Posts
    4

    Re: Number down column based on criteria of another and add up value

    Does not seem to work.

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

    Re: Number down column based on criteria of another and add up value

    The code assumes your starting values are in Columns A and B. Are they?

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

    Re: Number down column based on criteria of another and add up value

    Or?

    Sub mikesmoua()
    Dim i As Long, y As Long
    With Application
        .ScreenUpdating = False
        .Calculation = xlManual
    End With
    Columns(1).Insert
    For i = Range("B" & Rows.Count).End(3).row To 1 Step -1
        If Cells(i, "B") <> Cells(i + 1, "B") Then Rows(i + 1).Insert
    Next i
    y = 1
    For Each numrange In Columns(3).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            With numrange.Offset(numrange.Count, 1).Resize(1, 1)
                .Formula = "=SUM(" & sumaddr & ")"
                .Value = .Value
                .Cut numrange.Cells(1, 1).Offset(, 1)
            End With
            c = numrange.Count
            Range(sumaddr).Offset(, -2).Value = y
            y = y + 1
    Next numrange
    Range("B2:B" & Range("B" & Rows.Count).End(3).row).SpecialCells(4).EntireRow.Delete
    With Application
        .Calculation = xlAutomatic
        .ScreenUpdating = True
    End With
    End Sub

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Number down column based on criteria of another and add up value

    Is your starting point (e.g. s 2) all in a single cell? Is your desired output (eg 1 s 2 29) also ina single cell? If not, please post an Excel sheet showing what you DO want.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    The paperclip icon
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  7. #7
    Registered User
    Join Date
    11-18-2015
    Location
    Wisconsin, USA
    MS-Off Ver
    2010
    Posts
    4

    Re: Number down column based on criteria of another and add up value

    Okay, So the code did work. I think I can go off of this and tweak it. Thanks.

    I did try to upload a spread sheet but there may be something blocking it from uploading. Somewhat of a secure environment that I am in.

    Thanks again.

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

    Re: Number down column based on criteria of another and add up value

    You're welcome. Glad to help out and thanks for the feedback. If you are satisfied with the solutions provided please mark this thread as SOLVED.

  9. #9
    Registered User
    Join Date
    11-18-2015
    Location
    Wisconsin, USA
    MS-Off Ver
    2010
    Posts
    4

    Re: Number down column based on criteria of another and add up value

    How would I change this code if the column that I want to add is in column I. The total column to be in D. The column that determines the first number column is dependent on column C.

    I thought I would be able to tweak it but after multiple times of testing and teaking the code, I am still not able to figure it out. Thanks.
    Last edited by mikesmoua; 11-20-2015 at 10:41 AM.

+ 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: 2
    Last Post: 10-10-2015, 02:22 AM
  2. Replies: 2
    Last Post: 11-21-2014, 12:59 PM
  3. [SOLVED] Return Column Number Based On Multiple Criteria
    By taccoo73 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-17-2014, 10:03 PM
  4. Return column header based on column criteria and number value
    By bwill22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-07-2014, 07:33 PM
  5. [SOLVED] Marco for pivot table like fuctions. Subtotal column C, based on column B criteria.
    By RobertOHare in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2013, 02:57 PM
  6. Count number occurences based on criteria Column
    By SamCrome in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2013, 04:32 PM
  7. Add Random Number in a Column based on defined Number in another Column
    By Pack Dog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2010, 05:09 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