On Fri, 28 Nov 2003 19:35:16 -0800, adidas VBA wrote:
Can this formula be converted to a vba macro? If so, how??
This formula is copied down 35000 rows in column K of my worksheet
=IF(AND(IF(20030905=G2,IF(20030905<=H2,IF(MID(I2 ,5,1)="Y",1,0),0),0)=1,
IF(OR(A2="DTW",A2="MEM",A2="MSP",C2="DTW",C2="MEM ",C2="MSP"),IF(E2="CO",
0,1),IF(E2="NW",0,1))=1),1,0)
Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
First things first: converting this to VBA code will prevent it from
being automatically updated - you will have to run this code *every time
you want to update*. Also, by changing from a formula to VBA, it will go
from "practically instant" to "takes a few minutes". I would recommend
leaving it as a formula.
However, if it simply *must* be VBA:
Sub coffeeBreak()
Dim a1 As Boolean, a2 As Boolean, n As Long
For n = 2 To 35001
a1 = False
a2 = False
If 20030905 = Cells(n, 7).Value Then
If 20030905 = Cells(n, 8).Value Then
If Mid(Cells(n, 9).Value, 5, 1) = "Y" Then a1 = True
End If
End If
If (Cells(n, 1).Value = "DTW") Or _
(Cells(n, 1).Value = "MEM") Or _
(Cells(n, 1).Value = "MSP") Or _
(Cells(n, 3).Value = "DTW") Or _
(Cells(n, 3).Value = "MEM") Or _
(Cells(n, 3).Value = "MSP") _
Then
If Not (Cells(n, 5).Value = "CO") Then a2 = True
Else
If Not (Cells(n, 5).Value = "NW") Then a2 = True
End If
If (a1 And a2) Then
Cells(n, 11).Value = 1
Else
Cells(n, 11).Value = 0
End If
Next
End Sub
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
My Go amn keyboar oesn't have any 's!