![]() |
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 |
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. |
All times are GMT +1. The time now is 02:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com