#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Range Total

Hello everyone,

Anyone know why I'm not get the correct totals he
--
Dim iLastrow As Long
iLastrow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row

Range("B3").Select
Selection.End(xlDown)(3).Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[2]C:R[" & iLastrow & "]C)"

* e.g.: if I start from b3 to b138; b140 gets selected, but the subtotal is
b141:b142
** it should be b3:b138
--

Also how can I repeat this for muliple columns? If I have 10 columns then
the
sub-total should be done 10 times.

--

Any help will be greatly appreciated.

Have a goog day.
Himansu



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Range Total

Dim iLastrow As Long
Dim icol As Long
Dim i As Long

With ActiveCell
For i = 1 To 10
icol = .Column + i - 1
iLastrow = Cells(Rows.Count, icol).End(xlUp).Row
If iLastrow ActiveCell.Row Then
Cells(iLastrow + 1, icol).FormulaR1C1 = _
"=SUBTOTAL(9,R2C" & icol & ":R" & iLastrow & "C" & icol &
")"
End If
Next i
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Himansu" wrote in message
...
Hello everyone,

Anyone know why I'm not get the correct totals he
--
Dim iLastrow As Long
iLastrow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row

Range("B3").Select
Selection.End(xlDown)(3).Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[2]C:R[" & iLastrow & "]C)"

* e.g.: if I start from b3 to b138; b140 gets selected, but the subtotal

is
b141:b142
** it should be b3:b138
--

Also how can I repeat this for muliple columns? If I have 10 columns then
the
sub-total should be done 10 times.

--

Any help will be greatly appreciated.

Have a goog day.
Himansu





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Range Total

Bob-- thanks this worked. Is it possible to make the values BOLD within the
cells?
Maybe like:

Cells(iLastrow + 1, icol).FormulaR1C1.font.bold = true


"Bob Phillips" wrote in message
...
Dim iLastrow As Long
Dim icol As Long
Dim i As Long

With ActiveCell
For i = 1 To 10
icol = .Column + i - 1
iLastrow = Cells(Rows.Count, icol).End(xlUp).Row
If iLastrow ActiveCell.Row Then
Cells(iLastrow + 1, icol).FormulaR1C1 = _
"=SUBTOTAL(9,R2C" & icol & ":R" & iLastrow & "C" & icol &
")"
End If
Next i
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Himansu" wrote in message
...
Hello everyone,

Anyone know why I'm not get the correct totals he
--
Dim iLastrow As Long
iLastrow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row

Range("B3").Select
Selection.End(xlDown)(3).Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[2]C:R[" & iLastrow & "]C)"

* e.g.: if I start from b3 to b138; b140 gets selected, but the subtotal

is
b141:b142
** it should be b3:b138
--

Also how can I repeat this for muliple columns? If I have 10 columns

then
the
sub-total should be done 10 times.

--

Any help will be greatly appreciated.

Have a goog day.
Himansu







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Range Total

Cells(iLastrow + 1, icol).font.bold = True

--
Regards,
Tom Ogilvy

Himansu" wrote in message
...
Bob-- thanks this worked. Is it possible to make the values BOLD within

the
cells?
Maybe like:




"Bob Phillips" wrote in message
...
Dim iLastrow As Long
Dim icol As Long
Dim i As Long

With ActiveCell
For i = 1 To 10
icol = .Column + i - 1
iLastrow = Cells(Rows.Count, icol).End(xlUp).Row
If iLastrow ActiveCell.Row Then
Cells(iLastrow + 1, icol).FormulaR1C1 = _
"=SUBTOTAL(9,R2C" & icol & ":R" & iLastrow & "C" & icol

&
")"
End If
Next i
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Himansu" wrote in message
...
Hello everyone,

Anyone know why I'm not get the correct totals he
--
Dim iLastrow As Long
iLastrow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row

Range("B3").Select
Selection.End(xlDown)(3).Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[2]C:R[" & iLastrow & "]C)"

* e.g.: if I start from b3 to b138; b140 gets selected, but the

subtotal
is
b141:b142
** it should be b3:b138
--

Also how can I repeat this for muliple columns? If I have 10 columns

then
the
sub-total should be done 10 times.

--

Any help will be greatly appreciated.

Have a goog day.
Himansu









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Range Total

Excellent. You guys rock. I'm starting to REALLY REALLY
appreciate VB in Excel.



"Tom Ogilvy" wrote in message
...
Cells(iLastrow + 1, icol).font.bold = True

--
Regards,
Tom Ogilvy

Himansu" wrote in message
...
Bob-- thanks this worked. Is it possible to make the values BOLD within

the
cells?
Maybe like:




"Bob Phillips" wrote in message
...
Dim iLastrow As Long
Dim icol As Long
Dim i As Long

With ActiveCell
For i = 1 To 10
icol = .Column + i - 1
iLastrow = Cells(Rows.Count, icol).End(xlUp).Row
If iLastrow ActiveCell.Row Then
Cells(iLastrow + 1, icol).FormulaR1C1 = _
"=SUBTOTAL(9,R2C" & icol & ":R" & iLastrow & "C" &

icol
&
")"
End If
Next i
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Himansu" wrote in message
...
Hello everyone,

Anyone know why I'm not get the correct totals he
--
Dim iLastrow As Long
iLastrow = Cells(Rows.Count,

ActiveCell.Column).End(xlUp).Row

Range("B3").Select
Selection.End(xlDown)(3).Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[2]C:R[" & iLastrow &

"]C)"

* e.g.: if I start from b3 to b138; b140 gets selected, but the

subtotal
is
b141:b142
** it should be b3:b138
--

Also how can I repeat this for muliple columns? If I have 10

columns
then
the
sub-total should be done 10 times.

--

Any help will be greatly appreciated.

Have a goog day.
Himansu













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
TOTAL OF A RANGE SHOULD BE JOSEPH WEBER Excel Worksheet Functions 3 May 8th 09 06:18 PM
Total A Range Hamed parhizkar Excel Worksheet Functions 2 January 17th 08 06:21 PM
how to get a total to add up a range andyhofer Excel Worksheet Functions 1 March 27th 06 07:47 PM
How do I get the total of a range of cells that are in another she alice Excel Discussion (Misc queries) 1 November 24th 05 02:23 PM
Returning Range Total in VBA JimPNicholls Excel Programming 3 August 16th 04 04:48 PM


All times are GMT +1. The time now is 10:52 AM.

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"