View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1573_] Rick Rothstein \(MVP - VB\)[_1573_] is offline
external usenet poster
 
Posts: 1
Default Macro for IF formula

I am pretty sure this macro will do what you want...

Sub FixColumnA()
Dim X As Long
Dim LastCell As Long
Dim CurrentCell As Range
Dim AsciiOne As String
Dim FourTextValues As String
FourTextValues = AsciiOne & "TextValue1" & AsciiOne & "TextValue2" & _
AsciiOne & "TextValue3" & AsciiOne & "TextValue4" & _
AsciiOne
With Worksheets("Sheet1")
LastCell = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 1 To LastCell
If Len(.Cells(X, "A").Value) = 0 Then
If InStr(1, FourTextValues, .Cells(X, "B").Value, _
vbTextCompare) 0 And .Cells(X, "C").Value 0 Then
.Cells(X, "A").Value = .Cells(X, "B").Value
End If
End If
Next
End With
End Sub

Rick


"richzip" wrote in message
...
I have a large worksheet that I need a modified "IF" formula for. The
standard one won't work, and I think a macro is the way to go. ANy
suggestions for a macro code to accomplish the following:

If A1 contains a text value, leave that text value there and skip to A2
If A1 is blank, look at B1. If B1 contains any of 4 text values AND C1 is
0, then copy B1 to A1. If B1 does not contain one of those text values OR

C1=0, then A1 should remain blank.