View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Looping through a column

Sub AA()
dim rng as Range, cell as Range
set rng = Range(cells(1,"C"),cells(rows.count,"C").End(xlup) )
for each cell in rng
if lcase(cell.value) = "deficit" then
if isnumeric(cell.offset(0,-1)) then
cell.offset(0,-1).value = cell.Offset(0,-1).value * (-1)
end if
end if
Next
End Sub

--
regards,
Tom Ogilvy

"hudson40" wrote in
message ...

Hi

Its been a while since I've used excel and have a fairly easy question.
I'm trying to loop through a column (C). This column has either the word
'surplus' or 'deficit' in each cell. If the word is deficit I would like
to multiply the value in the preceeding col (B) by -1.

Any ideas greatly appreciated.


--
hudson40
------------------------------------------------------------------------
hudson40's Profile:

http://www.excelforum.com/member.php...o&userid=24681
View this thread: http://www.excelforum.com/showthread...hreadid=396105