Range Total

  • Thread starter Thread starter Himansu
  • Start date Start date
H

Himansu

Hello everyone,

Anyone know why I'm not get the correct totals here:
--
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
 
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)
 
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 said:
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 said:
Hello everyone,

Anyone know why I'm not get the correct totals here:
--
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
 
Cells(iLastrow + 1, icol).font.bold = True

--
Regards,
Tom Ogilvy

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




Bob Phillips said:
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 said:
Hello everyone,

Anyone know why I'm not get the correct totals here:
--
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
 
Excellent. You guys rock. I'm starting to REALLY REALLY
appreciate VB in Excel.



Tom Ogilvy said:
Cells(iLastrow + 1, icol).font.bold = True

--
Regards,
Tom Ogilvy

Himansu said:
Bob-- thanks this worked. Is it possible to make the values BOLD within the
cells?
Maybe like:
icol
&
")"
End If
Next i
End With


--

HTH

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


Hello everyone,

Anyone know why I'm not get the correct totals here:
--
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
columns
then
the
sub-total should be done 10 times.

--

Any help will be greatly appreciated.

Have a goog day.
Himansu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top