• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

What's wrong with my loop?

Bomino

Member
Hi everyone,
I need help troubleshooting my code or better yet help with a more efficient solution.
I wrote a code and it seems not to be doing what it is supposed to do: pulling data from a worksheet (Data) and populate a column in another worksheet (Main) based on value from dropdown. Here is my code:

Code:
Sub Retrieval()

    Dim x As Variant, y As Variant
    Dim RptDate As Range


With Application
    .EnableEvents = False
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
End With

    Lastrow = DATA.Cells(Rows.Count, 1).End(xlUp).Row
     
  y = 18
   
    For x = 6 To Lastrow
          If DATA.Cells(x, 2) = MAIN.Cells(2, 8) And DATA.Cells(x, 3) = MAIN.Cells(y, 6) Then
         
          MAIN.Cells(y, 13) = DATA.Cells(x, 10)
       
          y = y + 1
        End If
     
    Next
   
    With Application
        .EnableEvents = True
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
   
End Sub
Am I missing something?
Any help will be much appreciated.
Thank you.
I am also attaching a sample file
 

Attachments

  • Book2.xlsb
    25.9 KB · Views: 3
Bomino
How many same dates there should be?
Dates would be same format (dd/mm/yyyy or mm/dd/yyyy) not mixed.
... You would check Your SOW# compare too ... 'which-to-which'.
 
vletm,
Thank you for helping. There will be at most 14 same dates (or less depending on the data entry) because there are 14 different SOW#.
The date format is (mm/dd/yyyy). I still can't make it work.
 
Back
Top