View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NoodNutt[_2_] NoodNutt[_2_] is offline
external usenet poster
 
Posts: 39
Default Nested For statements

Hi Team

I sincerely trust you're all keeping well during this Topsy-turfy time.

This is my current code which works as expected:

Dim cRoute As String
Dim i As Integer

For i = 2 To 500
cRoute = Sheets("Conversion").Range("A" & i).Value
If Module3.testRouteSheetorAdd(cRoute) Then
Call Module3.transferCommittedRoute(cRoute, i)
End If
Next i

I would like to expand it so that it only creates sheets based on the value of another sheet (cStatus = "Y"):

This next code is not working:

Dim cRoute As String
Dim fRoute As String
Dim i As Integer
Dim j As Integer

For i = 5 To 50
cStatus = Sheets("Fleet Summary").Range("H" & i).Value
If cStatus = "Y" Then
fRoute = Sheets("Fleet Summary").Range("A" & i).Value
For j = 2 To 500
cRoute = Sheets("Conversion").Range("A" & j).Value
If cRoute = fRoute Then
If Module3.testRouteSheetorAdd(cRoute) Then
Call Module3.transferCommittedRoute(cRoute, j)
End If
End If
Next j
End If
Next i

As always, many thanks for any assistance.

Cheers
Mark