#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Active cell

Hi, i have this code:
Sub back()

Columns("I:I").Select
Selection.Find(What:="Total", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
End Sub
All i need is to sum all cells with data below active cell.
Can this be done?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Active cell

Sub dural()
Dim r As Range
Set r = Range(ActiveCell.Offset(1, 0), Cells(Rows.Count, ActiveCell.Column))
x = Application.WorksheetFunction.Sum(r)
MsgBox x
End Sub

--
Gary''s Student - gsnu200908
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Active cell

Hi Gary, it's working if i manually select last cell in "I" column that
contain word "Total".
The problem is that i dont need msgbox with the result. I need the result in
a cell. My code finds last cell in "I" column that contain "Total" and then
select next cell. I just need to sum cells below "Total" (last "total" in
range) and the result to be in a cell. I need the result to remain in my
table.
Can this be done?
Thanks!

"Gary''s Student" wrote:

Sub dural()
Dim r As Range
Set r = Range(ActiveCell.Offset(1, 0), Cells(Rows.Count, ActiveCell.Column))
x = Application.WorksheetFunction.Sum(r)
MsgBox x
End Sub

--
Gary''s Student - gsnu200908

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default Active cell

Give this code a try...

Sub Back()
Dim LastCell As Range
Set LastCell = Columns("I").Find(What:="Total", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False, SearchFormat:=False)
LastCell.Offset(1, 0).Value = Application.WorksheetFunction. _
Sum(Range(ActiveCell, LastCell))
End Sub

--
Rick (MVP - Excel)


"puiuluipui" wrote in message
...
Hi Gary, it's working if i manually select last cell in "I" column that
contain word "Total".
The problem is that i dont need msgbox with the result. I need the result
in
a cell. My code finds last cell in "I" column that contain "Total" and
then
select next cell. I just need to sum cells below "Total" (last "total" in
range) and the result to be in a cell. I need the result to remain in my
table.
Can this be done?
Thanks!

"Gary''s Student" wrote:

Sub dural()
Dim r As Range
Set r = Range(ActiveCell.Offset(1, 0), Cells(Rows.Count,
ActiveCell.Column))
x = Application.WorksheetFunction.Sum(r)
MsgBox x
End Sub

--
Gary''s Student - gsnu200908


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Active cell

Just change his
MsgBox x
statement to become
ActiveCell = x

or skip a step and change
x = Application.WorksheetFunction.Sum(r)
MsgBox x

to become simply
ActiveCell = Application.WorksheetFunction.Sum(r)


"puiuluipui" wrote:

Hi Gary, it's working if i manually select last cell in "I" column that
contain word "Total".
The problem is that i dont need msgbox with the result. I need the result in
a cell. My code finds last cell in "I" column that contain "Total" and then
select next cell. I just need to sum cells below "Total" (last "total" in
range) and the result to be in a cell. I need the result to remain in my
table.
Can this be done?
Thanks!

"Gary''s Student" wrote:

Sub dural()
Dim r As Range
Set r = Range(ActiveCell.Offset(1, 0), Cells(Rows.Count, ActiveCell.Column))
x = Application.WorksheetFunction.Sum(r)
MsgBox x
End Sub

--
Gary''s Student - gsnu200908

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
Active Cell? tgi Excel Discussion (Misc queries) 2 October 2nd 09 02:35 AM
set the background color of the current cell(active cell) kang New Users to Excel 2 July 31st 07 04:48 PM
referring to formula in a non active cell from active cell nickname Excel Discussion (Misc queries) 1 June 21st 07 12:11 PM
value of the active cell caroline Excel Worksheet Functions 2 June 21st 06 05:34 PM
HOW TO COPY 480 ACTIVE E-MAIL ADDRESSES CLM "G" ON AN ACTIVE EXCE. ragman10 Excel Discussion (Misc queries) 1 December 13th 04 11:52 PM


All times are GMT +1. The time now is 07:33 PM.

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"