Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm need to make a vba macro where the macro automaticly shall find the last row and make a summary of the total column D. I cant get It right, can someone please help? So far I only has typed following. Dim lngLastRow As Long lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row Range("D" & lngLastRow + 1) = _ -- Best regards Mia |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub slr()
dim mc as long Dim lr As Long mc = 4 'col D lr = Cells(Rows.Count, mc).End(xlUp).Row Cells(lr + 1, mc) = _ Application.Sum(Range(Cells(1, mc), Cells(lr, mc))) End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Mia" wrote in message ... Hi, I'm need to make a vba macro where the macro automaticly shall find the last row and make a summary of the total column D. I cant get It right, can someone please help? So far I only has typed following. Dim lngLastRow As Long lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row Range("D" & lngLastRow + 1) = _ -- Best regards Mia |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use this code. I assume Col. D has a header row so the code will
insert the SUM function in the cell below the last row with data in Col. D. Plus, you don't have to reference the ActiveSheet, in VBA it is assumed you mean the ActiveSheet. Hope this helps! If so, let me know, click "YES" below. Dim lngLastRow As Long ' find last row with data in Col.D lngLastRow = Cells(Rows.Count, "D").End(xlUp).Row ' insert sum formula Cells(lngLastRow + 1, "D").Formula = "=SUM(D2:D" & lngLastRow & ")" -- Cheers, Ryan "Mia" wrote: Hi, I'm need to make a vba macro where the macro automaticly shall find the last row and make a summary of the total column D. I cant get It right, can someone please help? So far I only has typed following. Dim lngLastRow As Long lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row Range("D" & lngLastRow + 1) = _ -- Best regards Mia |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you!
It works perfekt!!!! -- Best regards Mia "Don Guillett" skrev: Sub slr() dim mc as long Dim lr As Long mc = 4 'col D lr = Cells(Rows.Count, mc).End(xlUp).Row Cells(lr + 1, mc) = _ Application.Sum(Range(Cells(1, mc), Cells(lr, mc))) End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Mia" wrote in message ... Hi, I'm need to make a vba macro where the macro automaticly shall find the last row and make a summary of the total column D. I cant get It right, can someone please help? So far I only has typed following. Dim lngLastRow As Long lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row Range("D" & lngLastRow + 1) = _ -- Best regards Mia . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi again,
Thank you again for your help before. If I want the answer (the sum) to be in a special format, what shall I write? I want it to be bold and in curency (swedish kronor). Do you know how to code this? -- Best regards Mia "Don Guillett" skrev: Sub slr() dim mc as long Dim lr As Long mc = 4 'col D lr = Cells(Rows.Count, mc).End(xlUp).Row Cells(lr + 1, mc) = _ Application.Sum(Range(Cells(1, mc), Cells(lr, mc))) End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Mia" wrote in message ... Hi, I'm need to make a vba macro where the macro automaticly shall find the last row and make a summary of the total column D. I cant get It right, can someone please help? So far I only has typed following. Dim lngLastRow As Long lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row Range("D" & lngLastRow + 1) = _ -- Best regards Mia . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You would have to change properties on the Font collection.
Dim lngLastRow As Long ' find last row with data in Col.D lngLastRow = Cells(Rows.Count, "D").End(xlUp).Row ' insert sum formula With Cells(lngLastRow + 1, "D") .Formula = "=SUM(D2:D" & lngLastRow & ")" .Font.Bold = True .Font.Name = "Arial" .NumberFormat = "$#,##0.00" End With Hope this helps! If so, let me know, click "YES" below. -- Cheers, Ryan "Mia" wrote: Hi again, Thank you again for your help before. If I want the answer (the sum) to be in a special format, what shall I write? I want it to be bold and in curency (swedish kronor). Do you know how to code this? -- Best regards Mia "Don Guillett" skrev: Sub slr() dim mc as long Dim lr As Long mc = 4 'col D lr = Cells(Rows.Count, mc).End(xlUp).Row Cells(lr + 1, mc) = _ Application.Sum(Range(Cells(1, mc), Cells(lr, mc))) End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Mia" wrote in message ... Hi, I'm need to make a vba macro where the macro automaticly shall find the last row and make a summary of the total column D. I cant get It right, can someone please help? So far I only has typed following. Dim lngLastRow As Long lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row Range("D" & lngLastRow + 1) = _ -- Best regards Mia . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy two summary ranges to master summary sheet | Excel Programming | |||
multi group with summary above with 1 overall summary line below | Excel Discussion (Misc queries) | |||
multi group with summary above with 1 overall summary line below | Excel Discussion (Misc queries) | |||
Summary | Excel Worksheet Functions | |||
Summary Help | Excel Programming |