Not all matches with code for data copy from one Sheet to another appear

DThib

Active Member
Joined
Mar 19, 2010
Messages
464
Office Version
  1. 365
Platform
  1. Windows
Help!
I am getting some but not all matches with criteria match for data that gets copied and pasted from one Sheet to another.
The following code fires as needed, but I can count the number of misses.
This starts with the Access Database Query with the target data is opened and updated to be copied to a sheet in my workbook. The new data should be scanned for criteria and the matching row copied as shown.
What is going on?
Code:
Sub Workie()


  Dim LastRow, LR As Long
  Dim i As Long
  Dim j As Long
    
    LastRow = Cells(Rows.Count, "B").End(xlUp).Row
    j = LastRow + 1
    For i = 1 To LastRow
    
        If Sheets("Initial Query Pull").Cells(i, 29) <> "" And Sheets("Initial Query Pull").Cells(i, 11) = _
        "Assigned" And Sheets("Initial Query Pull").Cells(i, 16) = "" Then
             Sheets("Workable").Cells(j, 1) = Format(Now(), "DD-MMM-YYYY")
             Sheets("Workable").Cells(j, 2) = Sheets("Initial Query Pull").Cells(i, 2).Value
             Sheets("Workable").Cells(j, 3) = Sheets("Initial Query Pull").Cells(i, 10).Value
             Sheets("Workable").Cells(j, 4) = Sheets("Initial Query Pull").Cells(i, 9).Value
             Sheets("Workable").Cells(j, 5) = Sheets("Initial Query Pull").Cells(i, 29).Value
             Sheets("Workable").Cells(j, 6) = Sheets("Initial Query Pull").Cells(i, 5).Value
             Sheets("Workable").Cells(j, 7) = Sheets("Initial Query Pull").Cells(i, 6).Value
             Sheets("Workable").Cells(j, 8) = Sheets("Initial Query Pull").Cells(i, 30).Value
             Sheets("Workable").Cells(j, 9) = Sheets("Initial Query Pull").Cells(i, 8).Value 
             j = j + 1
        End If
    Next i
     
End Sub

DThib
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Maybe you have blank spaces in the cells:
Code:
"   "
instead of
""

or
Code:
"  Assigned       "
instead of

"Assigned"
 
Upvote 0
Thanks,
I tried it this morning and I am still getting partial results.
Here is the code:

Code:
Sub Assignie()


  Dim LastRow, LR As Long
  Dim i As Long
  Dim j As Long
    
    LastRow = Cells(Rows.Count, "B").End(xlUp).Row
    j = LastRow + 1


    For i = 1 To LastRow
       If (Sheets("Initial Query Pull").Cells(i, 8) = "" Or Sheets("Initial Query Pull").Cells(i, 8) = " " Or Sheets("Initial Query Pull").Cells(i, 7) = "" _
            Or Sheets("Initial Query Pull").Cells(i, 7) = " " Or Sheets("Initial Query Pull").Cells(i, 5) = "" Or Sheets("Initial Query Pull").Cells(i, 5) = " " _
            Or Sheets("Initial Query Pull").Cells(i, 10) = "" Or Sheets("Initial Query Pull").Cells(i, 10) = " " _
            Or Sheets("Initial Query Pull").Cells(i, 5) = "AIC Controller w/ Opt" Or Sheets("Initial Query Pull").Cells(i, 35) = "" Or _
            Sheets("Initial Query Pull").Cells(i, 34) = " " Or Sheets("Initial Query Pull").Cells(i, 34) = "" Or _
            Sheets("Initial Query Pull").Cells(i, 35) = " ") And (Sheets("Initial Query Pull").Cells(i, 5) = _
            "AIC Controller" Or Sheets("Initial Query Pull").Cells(i, 5) = "Remote Display Link") And _
            Sheets("Initial Query Pull").Cells(i, 2) <> "" Then
            
                Sheets("Assigned").Cells(j, 1) = Format(Now(), "DD-MMM-YYYY")
                Sheets("Assigned").Cells(j, 2) = Sheets("Initial Query Pull").Cells(i, 2).Value
                Sheets("Assigned").Cells(j, 3) = Sheets("Initial Query Pull").Cells(i, 10).Value
                Sheets("Assigned").Cells(j, 4) = Sheets("Initial Query Pull").Cells(i, 9).Value
                Sheets("Assigned").Cells(j, 5) = Sheets("Initial Query Pull").Cells(i, 5).Value
                Sheets("Assigned").Cells(j, 6) = Sheets("Initial Query Pull").Cells(i, 6).Value
                Sheets("Assigned").Cells(j, 7) = Sheets("Initial Query Pull").Cells(i, 30).Value
                Sheets("Assigned").Cells(j, 8) = Sheets("Initial Query Pull").Cells(i, 8).Value
                Sheets("Assigned").Cells(j, 9) = Sheets("Initial Query Pull").Cells(i, 32).Value
                Sheets("Assigned").Cells(j, 10) = Sheets("Initial Query Pull").Cells(i, 33).Value
                Sheets("Assigned").Cells(j, 11) = Sheets("Initial Query Pull").Cells(i, 7).Value
                'j = j + 1


       End If
    Next i
     'SPR| AssignedTo_Name|DateSPREntered|Product|Summary|Severity|SerialNumber1|Date Console DataReceived|Date Samples Received|Customer AccountSAP
       
End Sub

DThib
 
Upvote 0
This is a worksheet to be searched that will have roughly 3000 rows. It stops well before the end. What is going on?

DThib
 
Upvote 0
To continue the problem, If I fire the macro in the UserForm, again, I get more results. And the trend keeps happening.
I want this to search the entire array (in 1 worksheet) with a variable size.
I know I am missing a step but cannot figure out what it is.

Any ideas?

DThib
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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