Thread: Conditional
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Conditional

Hi
should the result in 'total fee' be dynamic or is it sufficient to run
a macro ones and insert the values? If yes try the following:
- select you cells which you want to process (thats is in your example
column B):
- start the following macro

sub total_insert()
dim rng as range
dim cell as range
dim ret_value
set rng = selection
ret_value=0
for each cell in rng
if cell.offset(0,-1).value="total fee" then
cell.value= ret_value
ret_value = 0
elseif cell.offset(0,-1).value = "ticket" or
cell.offset(0,-1).value = "transit" then
ret_value = ret_value + cell.value
end if
next
end sub


--
Regards
Frank Kabel
Frankfurt, Germany

Fee Discription $

total fee
ticket 10
light 50
transit 10
total fee

lets say i need to fill the cells to the lft of the "Total fee" cell
with the sum of ticket and transit fees.

one million thank yous


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