lanhao
10-18-2006, 02:02 PM
This is actually in reference to the second to last post I put up.
http://www.vbaexpress.com/forum/showthread.php?t=9859
Basically it is copying over the values, however, even after it's copied once, and i hit the copy button again so it would copy the new entries over, it grabs the old ones as well and brings them over.
Any suggestions on why it's not doing what it's supposed to do?
Sub Datamove()
'
' Datamove Macro
' Macro recorded 10/13/2006 by Andy Lewis
'
'Baseline variable list
'Counters for respective worksheet pages
Dim i As Integer
Dim k As Integer
Dim v As Integer
Dim eRow As Long
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Set sht1 = Worksheets("Uncorrected QC")
Application.ScreenUpdating = False
k = 2
With sht1
For v = 2 To .Cells(Rows.Count, 1).End(xlUp).Row Step 1
Dim shName As String
shName = sht1.Range("H" & k)
eRow = Sheets(shName).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
If sht1.Range("B" & k) <> Sheets(shName).Range("B" & v) And sht1.Range("D" & k) _
<> Sheets(shName).Range("D" & v) _
And sht1.Range("A" & k) <> Sheets(shName).Range("A" & v) And sht1.Range("F" & k) _
<> Sheets(shName).Range("F" & v) Then
sht1.Rows(k).Copy Destination:=Sheets(shName).Rows(eRow)
End If
k = k + 1
Next
End With
Application.ScreenUpdating = True
End Sub
Thanks muchly in advance for any help/suggestions that might be able to be given. :)
edited by Lucas: line breaks added to code
http://www.vbaexpress.com/forum/showthread.php?t=9859
Basically it is copying over the values, however, even after it's copied once, and i hit the copy button again so it would copy the new entries over, it grabs the old ones as well and brings them over.
Any suggestions on why it's not doing what it's supposed to do?
Sub Datamove()
'
' Datamove Macro
' Macro recorded 10/13/2006 by Andy Lewis
'
'Baseline variable list
'Counters for respective worksheet pages
Dim i As Integer
Dim k As Integer
Dim v As Integer
Dim eRow As Long
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Set sht1 = Worksheets("Uncorrected QC")
Application.ScreenUpdating = False
k = 2
With sht1
For v = 2 To .Cells(Rows.Count, 1).End(xlUp).Row Step 1
Dim shName As String
shName = sht1.Range("H" & k)
eRow = Sheets(shName).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
If sht1.Range("B" & k) <> Sheets(shName).Range("B" & v) And sht1.Range("D" & k) _
<> Sheets(shName).Range("D" & v) _
And sht1.Range("A" & k) <> Sheets(shName).Range("A" & v) And sht1.Range("F" & k) _
<> Sheets(shName).Range("F" & v) Then
sht1.Rows(k).Copy Destination:=Sheets(shName).Rows(eRow)
End If
k = k + 1
Next
End With
Application.ScreenUpdating = True
End Sub
Thanks muchly in advance for any help/suggestions that might be able to be given. :)
edited by Lucas: line breaks added to code