Macro if condition
Give this a try..
Sub Macro()
Dim varFound As Variant, arrFind As Variant, strAddress As String
Dim intFind As Integer
arrFind = Array("Inv", "Pen")
For intFind = 0 To UBound(arrFind)
With ActiveSheet.Range("C:C")
Set varFound = .Find(arrFind(intFind), , xlValues, 1)
If Not varFound Is Nothing Then
strAddress = varFound.Address
Do
Range("D" & varFound.Row).Resize(, 4) = Split("name,val,date,reason", ",")
With Range("D" & varFound.Row).Resize(, 4).Font
.Name = "Arial": .Size = 12: .Bold = True
End With
Set varFound = .FindNext(varFound)
Loop While Not varFound Is Nothing And _
varFound.Address < strAddress
End If
End With
Next
End Sub
If this post helps click Yes
---------------
Jacob Skaria
"puiuluipui" wrote:
Hi, i need a macro to add some text if a value is found in "C" column.
If in C column i write "Inv", then to add from next cell this :
(name,val,date,reason) and to format all to arial bold 12
If in C column i write "Pen", then to add from next cell this :
(name,time,date,reason) and to format all to arial bold 12
Ex:
Inv name val date reason
Pen name tine date reason
Can this be done?
Thanks!
|