Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculating totals if a condition is met

Hi,

I have written the following macro. What I need is that when the nex
"Result" is found the "temp" range should change to that row.

Currently temp stays at Range("G13")

Please help.

Thanks

Sub testcalc()
Dim temp As Range

Set temp = Range("G13")
total = 0

Cells(13, "D").Select
While ActiveCell.Value < ""
If Cells(ActiveCell.Row, "D").Value = "Result" Then
Cells(ActiveCell.Row, "G").Value = 0
temp = Cells(ActiveCell.Row, "G")
total = Cells(ActiveCell.Row, "G").Value
temp = Cells(ActiveCell.Row).Address
Else
If ActiveCell.Value < "Result" Then
total = total + Cells(ActiveCell.Row, "G").Value

End If
End If
Cells(ActiveCell.Row + 1, "D").Select
temp = total

Wend
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Calculating totals if a condition is met

here is code for find:
Cells.Find(What:="Results", After:=ActiveCell,
Lookin:=xlFormulas,_
LookAt:=xlPart, SearchOrder:=xlByRows,
searchDirection:=xlnext,_
MatchCase:=False).Activate

-----Original Message-----
Hi,

I have written the following macro. What I need is that

when the next
"Result" is found the "temp" range should change to that

row.

Currently temp stays at Range("G13")

Please help.

Thanks

Sub testcalc()
Dim temp As Range

Set temp = Range("G13")
total = 0

Cells(13, "D").Select
While ActiveCell.Value < ""
If Cells(ActiveCell.Row, "D").Value = "Result" Then
Cells(ActiveCell.Row, "G").Value = 0
temp = Cells(ActiveCell.Row, "G")
total = Cells(ActiveCell.Row, "G").Value
temp = Cells(ActiveCell.Row).Address
Else
If ActiveCell.Value < "Result" Then
total = total + Cells(ActiveCell.Row, "G").Value

End If
End If
Cells(ActiveCell.Row + 1, "D").Select
temp = total

Wend
End Sub


---
Message posted from http://www.ExcelForum.com/

.

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
Calculating totals from COUNTA function MW New Users to Excel 3 March 13th 07 04:53 PM
Calculating montlhy totals using sumproduct (or other) [email protected] Excel Discussion (Misc queries) 2 June 7th 06 07:03 PM
Calculating monthly totals Pieman Excel Worksheet Functions 10 February 26th 06 04:55 PM
Calculating totals Blissfully Ignorant Excel Discussion (Misc queries) 1 December 6th 05 04:03 PM
Help calculating totals Gary Excel Discussion (Misc queries) 1 February 3rd 05 10:33 PM


All times are GMT +1. The time now is 03:16 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"