ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Setting up and Configuration of Excel (https://www.excelbanter.com/setting-up-configuration-excel/)
-   -   Activate cell at end of range (https://www.excelbanter.com/setting-up-configuration-excel/56601-activate-cell-end-range.html)

G

Activate cell at end of range
 
I want to be able to automatically find the last cell in the range, offset
(1,0) and activate/select the cell to place the sum of the range. The code
below does not activate the cell at the end to properly place the total
amount. Any help is greatly appreciated!

Sub AddTotal()
With ActiveCell
Set Rng = Range("K8", Range("K8").End(xlDown))
.Formula = "=SUM(" & Rng.Address & ")"
End With
End Sub

G

Bob Phillips

Activate cell at end of range
 
Sub AddTotal()
Set rng2 = Range("K8").End(xlDown)
Set rng = Range("K8", rng2)
rng2.Offset(1, 0).Formula = "=SUM(" & rng.Address & ")"
End Sub


--

HTH

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


"G" wrote in message
...
I want to be able to automatically find the last cell in the range, offset
(1,0) and activate/select the cell to place the sum of the range. The

code
below does not activate the cell at the end to properly place the total
amount. Any help is greatly appreciated!

Sub AddTotal()
With ActiveCell
Set Rng = Range("K8", Range("K8").End(xlDown))
.Formula = "=SUM(" & Rng.Address & ")"
End With
End Sub

G




G

Activate cell at end of range
 
Thanks for your quick response! The coding definitely works!

"Bob Phillips" wrote:

Sub AddTotal()
Set rng2 = Range("K8").End(xlDown)
Set rng = Range("K8", rng2)
rng2.Offset(1, 0).Formula = "=SUM(" & rng.Address & ")"
End Sub


--

HTH

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


"G" wrote in message
...
I want to be able to automatically find the last cell in the range, offset
(1,0) and activate/select the cell to place the sum of the range. The

code
below does not activate the cell at the end to properly place the total
amount. Any help is greatly appreciated!

Sub AddTotal()
With ActiveCell
Set Rng = Range("K8", Range("K8").End(xlDown))
.Formula = "=SUM(" & Rng.Address & ")"
End With
End Sub

G






All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com