+ Reply to Thread
Results 1 to 5 of 5

Sum a column as long as another column's cell contains data

  1. #1
    Registered User
    Join Date
    02-17-2014
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    37

    Sum a column as long as another column's cell contains data

    Hello,

    I have a spreadsheet and I would like to run a macro to automatically sum the values of column E at the bottom of column E at the first occurence of a blank cell in Column A. So if Column A has no more values starting at A10 then E10 is the Sum of E1-E9. I want to do the same for Column F too (Sum of F1-F9).

    The second part of the problem is that I have already recorded a macro and would like to add this on. I don't have ANY experience with coding and the macro was recorded by me simply going through the motions. I do know how to go in and look at what I've recorded but none of it means anything to me so my second question is at what point in the macro below would I cut and paste the solution to the above into this:

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    ' Keyboard Shortcut: Ctrl+i
    '
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    Columns("A:G").Select
    Selection.Delete Shift:=xlToLeft
    Columns("C:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("C:C").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("E:G").Select
    Selection.Delete Shift:=xlToLeft
    Columns("G:G").Select
    Selection.Delete Shift:=xlToLeft
    Application.WindowState = xlNormal
    Application.Left = 296.5
    Application.Top = 103.75
    Columns("A:A").Select
    With Selection
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlTop
    .WrapText = False
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
    End With
    Application.Left = 169
    Application.Top = 112
    Columns("E:E").Select
    Selection.Cut Destination:=Columns("P:P")
    Columns("D:D").Select
    Selection.Replace What:="GIFT", Replacement:="Gift", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="PP", Replacement:="Pledge Payment", LookAt:= _
    xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="PLEDGE", Replacement:="Pledge", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Range("E2").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[1]>0,"""",RC[1])"
    Range("E2").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[1]>0,"""",RC[11])"
    Range("E2").Select
    Selection.AutoFill Destination:=Range("E2:E32")
    Range("E2:E32").Select
    Columns("E:F").Select
    Selection.Style = "Currency"
    Cells.Select
    Cells.EntireColumn.AutoFit
    With Selection.Font
    .Name = "ARIAL"
    .Size = 8
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = 1
    .TintAndShade = 0
    .ThemeFont = xlThemeFontNone
    End With
    End Sub


    Thank you in advance for your help!

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Sum a column as long as another column's cell contains data

    Here is the answer to your first question.
    Please Login or Register  to view this content.

    As to your second question, it would be quicker and easier for me if you told me what you were trying to do in your recorded macro rather than trying to read through all the excess code that comes with a recorded macro.

  3. #3
    Registered User
    Join Date
    02-17-2014
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    37

    Re: Sum a column as long as another column's cell contains data

    Thank you stnkynts!!! I actually should not have bothered to cut and paste all that. It was just meanderings of me deleting this cell, changing the font size of another cell, etc. as I recorded a macro. I just wondered if I could cut and paste (eg., between the last line of the macro I have there and before the "End Sub" of my macro) what you have here so that I only have to press the "ctrl i" that I assigned to it once rather than creating a separate command and having to do two for one worksheet.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Sum a column as long as another column's cell contains data

    I have no idea what you are trying to say. Maybe submit an example workbook demonstrating the message you are trying to convey.

  5. #5
    Registered User
    Join Date
    02-17-2014
    Location
    New York
    MS-Off Ver
    Office 365
    Posts
    37

    Re: Sum a column as long as another column's cell contains data

    stnkynts, thanks for helping with this. I took your response to an excel office hours and it was used as a guide to come up with what I needed. Still a little advanced for me so I will probably go back to the basic and try to understand how to write a macro rather than record one.

+ 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. Macro for extracting data from a long column and insert it in its own column with a header
    By ChemistryStudent in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2014, 04:41 AM
  2. Replies: 12
    Last Post: 06-26-2013, 02:39 AM
  3. [SOLVED] Count Duplicates in Column A once as long as there is a number higher than 0 in Column B
    By armbands1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-05-2013, 01:46 AM
  4. Replies: 3
    Last Post: 02-13-2013, 04:05 PM
  5. Multiple columns of data into one long column
    By beatrice25 in forum Excel General
    Replies: 2
    Last Post: 05-20-2006, 08:18 PM

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