Well, just when i thought i had everything covered on this thing...
I am running into a problem with one part of the code specifically not working. I need to have it check to see if a value is on a target spreadsheet, if it finds that value, it has to check to see if two other cells on the same row are also the same (basically I'm checking three values on one row and seeing if they match between two sheets). If they don't, it will copy the row over.
The problem that I am running into on this is that if it finds the first value, and doesn't match up to the other values on that row, it will just copy it. I need it to go to the next instance of that value showing up adn compare to that one as well (basically having issues with the findnext layout in this code).
I apologize for being a contstant pain on this, and I do want to thank you for all the help and suggestions that have been given up to this point, and also any help in the present as well.
[vba]Sub Datamove()
'
' Datamove Macro
' Macro recorded 10/13/2006 by Andy Lewis
'
'Baseline variable list
Set sht1 = Worksheets("Uncorrected QC")
'Counters for respective worksheet pages
Dim i As Integer
Dim k As Integer 'Row counter for sht1
Dim v As Integer
Dim tick As Long 'Counter for records copied
Dim eRow As Long 'Last row on sht2
Dim sht2 As Worksheet 'worksheet that will change name depending on a value
Dim Tac As String, Trep As String, Tindt As String 'values based on the find function
Application.ScreenUpdating = False
k = 2
v = 2
tick = 0
With sht1
For v = 2 To sht1.Cells(Rows.Count, "A").End(xlUp).Row 'Goes through each row on sht1
Dim shName As String
shName = sht1.Cells(k, "H")
Set sht2 = Sheets(shName)
eRow = sht2.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
Dim c As Range
Set c = sht2.Columns(2).Find(sht1.Cells(k, "B").Value)
'If it finds no match, it copies the row from sht1 to the respective sheet
If c Is Nothing Then
Set c = Nothing
sht1.Rows(k).Copy Destination:=sht2.Rows(eRow)
tick = tick + 1
'If it does find a match value wise, it compares those two cells as well
'to see if they match
Else
'MsgBox "Already Exists"
FirstAddr = c.Address
Do
Set c = sht2.Columns(2).FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddr
Tac = c.Address
Trep = c.Offset(0, 2).Value
Tindt = c.Offset(0, 3).Value
If Trep <> sht1.Cells(k, "D").Value And Tindt <> sht1.Cells(k, "E").Value Then
sht1.Rows(k).Copy Destination:=sht2.Rows(eRow)
tick = tick + 1
'If it finds that either of the two variables don't match -
'it will copy the row over
End If
'Does nothing else
End If
k = k + 1
Next v
MsgBox "Records copied: " & tick
End With
Application.ScreenUpdating = True
End Sub
[/vba]
Edited 31-Oct-06 by geekgirlau. Reason: insert line breaks