Missing a step in VBA Proceedure

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
Good morning,

I am running the following code..I Know its crude but mostly it works, however on one of the sheets it misses a few weeks out when searching where i is = 2,4,6,8 but picks the person up again when i is = 10,12 and 14.....any ideas...for the rest of the worksheets it seems to be fine but i am still checking

Code:
Sub BringWeek()
Dim sh As Worksheet
Dim NextRow As Integer
Range("A11:O29").ClearContents
Application.ScreenUpdating = False
Dat = Worksheets("Holidays").Cells(5, 1).Value
NextRow = 11
For y = 3 To 53
For x = 2 To 14 Step 2
For i = 5 To 57
Worksheets(y).Activate
    If Cells(i, x) = "H" And Cells(i, 1) = Dat Then
        Worksheets("Holidays").Cells(NextRow, 2).Value = Cells(i, 2)
        Worksheets("Holidays").Cells(NextRow, 4).Value = Cells(i, 4)
        Worksheets("Holidays").Cells(NextRow, 6).Value = Cells(i, 6)
        Worksheets("Holidays").Cells(NextRow, 8).Value = Cells(i, 8)
        Worksheets("Holidays").Cells(NextRow, 10).Value = Cells(i, 10)
        Worksheets("Holidays").Cells(NextRow, 12).Value = Cells(i, 12)
        Worksheets("Holidays").Cells(NextRow, 14).Value = Cells(i, 14)
        Worksheets("Holidays").Cells(NextRow, 1).Value = Cells(1, 4)
    y = y + 1
    NextRow = NextRow + 1
    End If
    
    Next i
    Next x
    Next y
    Application.ScreenUpdating = True
   
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
As a guess I'd say that the cells don't match in those cases. Check cell length for unwanted spaces etc etc.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top