Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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






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
Variable Range James C. Excel Discussion (Misc queries) 3 April 2nd 09 12:41 AM
from Range variable Marina Limeira Charts and Charting in Excel 0 January 22nd 06 02:35 PM
Using a variable in a range Tempy Excel Programming 5 May 20th 05 08:54 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 09:17 AM.

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

About Us

"It's about Microsoft Excel"