VBA Help to replace If formula
Hosyar,
Here is a macro
Sub Test()
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If InStr(1, LCase(Cells(i, "A").Value), "equip") 0 Then
Cells(i, "B").Value = "EQUIP"
End If
Next i
End Sub
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Hoshyar" wrote in message
...
Hi Bob,
Many thanks it worked. But imagine that I have 2000 rows and I have to
copy
this formula in those rows which Ihave already did and it works. I was
thinking of a VBA function just to avoid increas in the size of the
documnets. Anyhow if there is no more alternative to this, this is still
great. and thanks once again.
Hoshyar
"Bob Phillips" wrote:
You could just look for Equip in the filed, like so
=IF(ISNUMBER(SEARCH("equip",A1)),"EQUIP","")
or
=IF(ISNUMBER(FIND("Equip",A1)),"EQUIP","")
if it needs to be case sensitive.
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Hoshyar" wrote in message
...
Hi All,
Column "A" is a category column, I always choos from a drop down list
these
categories " Security Equip, IT Equip, HSE Equip, Comms Equip, Ops
Equip"
in
column "A".
Whenever these categories appears in column "A", I want to give them
one
name for all of them in cluumn "K", such as "EQUIP". is it possible
to do
that automatically?
currently I am using this formula in each cell in clumn "K"
=IF(A1="Office Equip","EQUIP",IF(A1="Comms.
Equip","EQUIP",IF(A1="Security
Equip","EQUIP",IF(A1="Vehicles Equip","EQUIP",IF(A1="Ops
Equip","EQUIP",IF(A1="SHE Equip","EQUIP",IF(A1="IT
Equip","EQUIP","")))))))
But this is a very long formla and it increases the size of my spread
sheet.
Your help is appreciated
Best regards
Hoshyar
|