Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping through a column


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



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
count rows in a column for looping damorrison Excel Discussion (Misc queries) 2 April 8th 07 10:30 PM
Looping until empty column theguz[_3_] Excel Programming 2 August 4th 05 11:29 PM
Looping until empty column theguz Excel Discussion (Misc queries) 1 August 4th 05 07:04 PM
Multiple Column Cell Compare looping through Rows nickg420[_7_] Excel Programming 2 August 2nd 04 05:15 PM
looping from one column to the next Brad Zenner Excel Programming 0 July 21st 03 08:41 PM


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