Please can you help an excel novice with a question on how to write a formula using the IF function to detect certain text in a column of a spreadsheet and then to turn numbers in three other columns into negatives if that text is true? Thank you
=IF(ISNUMBER(FIND("dog",A1)),0-B1,B1)
Welcome to the Board!
Let's say that you are looking for the word "dog" in A1, and if it exists, take the negative value of the entry in cell B1.
Then that formula would look like this:
Code:=IF(ISNUMBER(FIND("dog",A1)),0-B1,B1)
Is that what you are after?
Any cell can either have a hard-coded value, or a formula, but not both at the same time.Sorry, maybe I should have explained it better! I actually have 3 columns of numbers which I have extracted from an accounts package but the credits haven't come through as negatives so they are throwing off my totals - I want to look for all the credit notes (marked "CRN" in column A) and then turn the positive numbers in columns C,D and E to negative, is that even possible?!
Welcome to the board dci1966
What is in the other 3 columns?
- values?
- formula?
Sub MyNumFix()
Dim lr As Long
Dim r As Long
Dim c As Long
Application.ScreenUpdating = False
' Find last row with data in column A
lr = Cells(Rows.Count, "A").End(xlUp).Row
' Loop through all rows of data
For r = 1 To lr
' Check to see if column A equals "CRN"
If Cells(r, "A") = "CRN" Then
' Negate values in columns C-E
For c = 3 To 5
Cells(r, c) = 0 - Cells(r, c)
Next c
End If
Next r
Application.ScreenUpdating = True
End Sub
Any cell can either have a hard-coded value, or a formula, but not both at the same time.
So to change existing hard-coded values in cells, that will require VBA. Is that something you are willing to use?
If so, are the cells EXACTLY equal to "CRN", or is part of a larger string?
You don't need to understand it or know how to write it in order to use it.LOL definitely not up to VBA!!!!!!