Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to find a static value in a cell and then subtract from adjacent cell

Hello,

I'm trying to write a macro that will look at a series of cells for a specific
word. If the word it is found, it will subtract the value from the cell
adjacent to the cell it found the word in.

For instance, loop through cells E32 - E42. If word, "Paul" is found
in cell E32, subtract value in cell F32 from cell D25. Otherwise if word,
"Paul" is found in cell E33, subtract value in cell F33 from cell D25.
If "Paul" is found in E32 and E33, subtract values in F32 and F33
from D25.

D25 is static. The value to subtract is dynamic based on the values in column
E.

Please help!

Thanks,
Jihaan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Need to find a static value in a cell and then subtract from adjacent cell

jihaan wrote:

I'm trying to write a macro that will look at a series of cells for a
specific word. If the word it is found, it will subtract the value
from the cell adjacent to the cell it found the word in.

For instance, loop through cells E32 - E42. If word, "Paul" is found
in cell E32, subtract value in cell F32 from cell D25. Otherwise if
word, "Paul" is found in cell E33, subtract value in cell F33 from cell
D25. If "Paul" is found in E32 and E33, subtract values in F32 and F33
from D25.

D25 is static. The value to subtract is dynamic based on the values in
column E.


You practically wrote the code yourself:

For n = 32 To 42
If InStr(Cells(n, 5).Value, "Paul") Then
Range("D25").Value = Range("D25").Value - Cells(n, 6).Value
End If
Next

--
It's what I call an Insult of Opportunity.
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
Find duplicate, but only if an adjacent cell is identical [email protected] Excel Worksheet Functions 2 July 30th 08 02:14 PM
find lowest number and return it's adjacent cell Erik Excel Worksheet Functions 7 October 2nd 07 02:37 PM
Find a cell and then insert a formula into adjacent cell crowdx42[_8_] Excel Programming 7 August 21st 06 02:53 PM
find data in adjacent cell Leon Jaeggi Excel Discussion (Misc queries) 2 May 27th 06 01:36 PM
Find Cell and Copy adjacent value to another location JJalomo Excel Programming 2 March 8th 05 07:17 PM


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