View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
coventry england coventry england is offline
external usenet poster
 
Posts: 8
Default Modify code from one macro to another...any takers?

Help. How can this code be modified....


----------------------------------------------
Sub sched()
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

-----------------------------------------------------------

To match this...............

Function schedulecleanup(rowNum As Long) As Integer
If Cells(rowNum, 7).Value 20030905 Or _
Cells(rowNum, 8).Value < 20030905 Or _
UCase(Mid(Cells(rowNum, 9).Value, 5, 1)) < "Y" Then
schedulecleanup = 0
Exit Function
End If

Select Case UCase(Cells(rowNum, 5).Value)
Case "NW"
Select Case UCase(Cells(rowNum, 1))
Case "DTW", "MEM", "MSP" 'condition 1
schedulecleanup = 1
Case Else
Select Case UCase(Cells(rowNum, 3))
Case "DTW", "MEM", "MSP" 'condition 1
schedulecleanup = 1
Case Else 'condition 2
schedulecleanup = 0
End Select
End Select
Case "CO"
Select Case UCase(Cells(rowNum, 1))
Case "DTW", "MEM", "MSP" 'condition 3
schedulecleanup = 0
Case Else
Select Case UCase(Cells(rowNum, 3))
Case "DTW", "MEM", "MSP" 'condition 3
schedulecleanup = 0
Case Else 'condition 4
schedulecleanup = 1
End Select
End Select
Case Else 'condition 5
schedulecleanup = 1
End Select
End Function


Sub cleanuptime()
For x = 2 To 30001
Cells(x, 12).Value = schedulecleanup(x)
Next
End Sub

----------------------------------------------------

Please help.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!