Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default Summary in the last row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Summary in the last row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Summary in the last row

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   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default Summary in the last row

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   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default Summary in the last row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Summary in the last row

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy two summary ranges to master summary sheet a m spock Excel Programming 5 September 13th 08 01:49 PM
multi group with summary above with 1 overall summary line below Freddy Excel Discussion (Misc queries) 2 November 7th 05 03:30 PM
multi group with summary above with 1 overall summary line below Freddy Excel Discussion (Misc queries) 1 November 1st 05 08:50 PM
Summary [email protected] Excel Worksheet Functions 2 February 2nd 05 05:46 AM
Summary Help Michael168[_63_] Excel Programming 0 November 13th 03 09:21 AM


All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"