![]() |
sum on a variable range
Hi all,
I have a macro that open a form The user fill an excel sheet with this form So i have a growing number of lines in the excel sheet. I just want to sum colum D from the second line up to the end and display the total on the form each time a line is created on the excel sheet How can i do that? regards, Pierre |
sum on a variable range
Pierre,
Code like: UserForm1.TextBox1.Text = Application.WorksheetFunction.Sum( _ Worksheets("Sheet1").Range("D2", Worksheets("Sheet1").Range("D2").End(xlDown))) Tie it into one of your events. HTH, Bernie MS Excel MVP "Pierre" wrote in message ... Hi all, I have a macro that open a form The user fill an excel sheet with this form So i have a growing number of lines in the excel sheet. I just want to sum colum D from the second line up to the end and display the total on the form each time a line is created on the excel sheet How can i do that? regards, Pierre |
sum on a variable range
lastrow = worksheets("Sheet1").Cells(rows.count,4).End(xlup) .row
Userform1.Textbox1.Value = Application.Sum(worksheets("Sheet1").Range("D2") _ .Resize(lastrow - 1,1)) Place in the appropriate event. -- Regards, Tom Ogilvy "Pierre" wrote in message ... Hi all, I have a macro that open a form The user fill an excel sheet with this form So i have a growing number of lines in the excel sheet. I just want to sum colum D from the second line up to the end and display the total on the form each time a line is created on the excel sheet How can i do that? regards, Pierre |
sum on a variable range
Application.SUM("D2:D" & Cells(Rows.Count,"D").End(xlUp).Row)
-- HTH RP (remove nothere from the email address if mailing direct) "Pierre" wrote in message ... Hi all, I have a macro that open a form The user fill an excel sheet with this form So i have a growing number of lines in the excel sheet. I just want to sum colum D from the second line up to the end and display the total on the form each time a line is created on the excel sheet How can i do that? regards, Pierre |
sum on a variable range
work good, thanks all
Bob Phillips a écrit dans le message ... Application.SUM("D2:D" & Cells(Rows.Count,"D").End(xlUp).Row) -- HTH RP (remove nothere from the email address if mailing direct) "Pierre" wrote in message ... Hi all, I have a macro that open a form The user fill an excel sheet with this form So i have a growing number of lines in the excel sheet. I just want to sum colum D from the second line up to the end and display the total on the form each time a line is created on the excel sheet How can i do that? regards, Pierre |
All times are GMT +1. The time now is 01:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com