Я хочу взять данные из моей рабочей таблицы Dump, проверить, существует ли значение в столбце A в столбце A моей рабочей таблицы RA. Если это так, скопируйте всю строку целиком и вставьте ее на вкладку RA, если не разместите данные на вкладке Acq. В настоящее время у меня это работает, но это занимает вечность, и я чувствую, что должен быть способ сделать это с помощью диапазона, но часть "j.row j.column" ставит меня в тупик. Любой совет?
Private Sub CommandButton1_Click()
Dim Dump As Worksheet
Dim RA As Worksheet
Dim Acq As Worksheet
Dim i As Integer
Set Dump = Worksheets("Dump")
Set RA = Worksheets("Retained Revenue Achieved")
Set Acq = Worksheets("New Business Revenue Achieved")
k = Dump.Cells(Rows.Count, "A").End(xlUp).Row + 1
'check through each row in the Dump'
For i = 5 To k
findvalue = Dump.Cells(i, 1).Value
Set J = RA.Range("A:A").Find(findvalue)
'if the customer id exists in RA then copy and paste the row from Dump to RA'
If Not J Is Nothing Then
RA.Cells(J.Row, J.Column).Offset(0, 1).Value = Dump.Cells(i, 2).Value
RA.Cells(J.Row, J.Column).Offset(0, 2).Value = Dump.Cells(i, 3).Value
RA.Cells(J.Row, J.Column).Offset(0, 3).Value = Dump.Cells(i, 4).Value
RA.Cells(J.Row, J.Column).Offset(0, 4).Value = Dump.Cells(i, 5).Value
RA.Cells(J.Row, J.Column).Offset(0, 5).Value = Dump.Cells(i, 6).Value
RA.Cells(J.Row, J.Column).Offset(0, 6).Value = Dump.Cells(i, 7).Value
RA.Cells(J.Row, J.Column).Offset(0, 7).Value = Dump.Cells(i, 8).Value
RA.Cells(J.Row, J.Column).Offset(0, 8).Value = Dump.Cells(i, 9).Value
RA.Cells(J.Row, J.Column).Offset(0, 9).Value = Dump.Cells(i, 10).Value
RA.Cells(J.Row, J.Column).Offset(0, 10).Value = Dump.Cells(i, 11).Value
RA.Cells(J.Row, J.Column).Offset(0, 11).Value = Dump.Cells(i, 12).Value
RA.Cells(J.Row, J.Column).Offset(0, 12).Value = Dump.Cells(i, 13).Value
RA.Cells(J.Row, J.Column).Offset(0, 13).Value = Dump.Cells(i, 14).Value
RA.Cells(J.Row, J.Column).Offset(0, 14).Value = Dump.Cells(i, 15).Value
RA.Cells(J.Row, J.Column).Offset(0, 15).Value = Dump.Cells(i, 16).Value
RA.Cells(J.Row, J.Column).Offset(0, 16).Value = Dump.Cells(i, 17).Value
RA.Cells(J.Row, J.Column).Offset(0, 17).Value = Dump.Cells(i, 18).Value
RA.Cells(J.Row, J.Column).Offset(0, 18).Value = Dump.Cells(i, 19).Value
RA.Cells(J.Row, J.Column).Offset(0, 19).Value = Dump.Cells(i, 20).Value
RA.Cells(J.Row, J.Column).Offset(0, 20).Value = Dump.Cells(i, 21).Value
RA.Cells(J.Row, J.Column).Offset(0, 21).Value = Dump.Cells(i, 22).Value
RA.Cells(J.Row, J.Column).Offset(0, 22).Value = Dump.Cells(i, 23).Value
RA.Cells(J.Row, J.Column).Offset(0, 23).Value = Dump.Cells(i, 24).Value
RA.Cells(J.Row, J.Column).Offset(0, 24).Value = Dump.Cells(i, 25).Value
RA.Cells(J.Row, J.Column).Offset(0, 25).Value = Dump.Cells(i, 26).Value
RA.Cells(J.Row, J.Column).Offset(0, 26).Value = Dump.Cells(i, 27).Value
RA.Cells(J.Row, J.Column).Offset(0, 27).Value = Dump.Cells(i, 28).Value
RA.Cells(J.Row, J.Column).Offset(0, 28).Value = Dump.Cells(i, 29).Value
RA.Cells(J.Row, J.Column).Offset(0, 29).Value = Dump.Cells(i, 30).Value
RA.Cells(J.Row, J.Column).Offset(0, 30).Value = Dump.Cells(i, 31).Value
RA.Cells(J.Row, J.Column).Offset(0, 31).Value = Dump.Cells(i, 32).Value
RA.Cells(J.Row, J.Column).Offset(0, 32).Value = Dump.Cells(i, 33).Value
RA.Cells(J.Row, J.Column).Offset(0, 33).Value = Dump.Cells(i, 34).Value
RA.Cells(J.Row, J.Column).Offset(0, 34).Value = Dump.Cells(i, 35).Value
RA.Cells(J.Row, J.Column).Offset(0, 35).Value = Dump.Cells(i, 36).Value
RA.Cells(J.Row, J.Column).Offset(0, 36).Value = Dump.Cells(i, 37).Value
RA.Cells(J.Row, J.Column).Offset(0, 37).Value = Dump.Cells(i, 38).Value
RA.Cells(J.Row, J.Column).Offset(0, 38).Value = Dump.Cells(i, 39).Value
RA.Cells(J.Row, J.Column).Offset(0, 39).Value = Dump.Cells(i, 40).Value
RA.Cells(J.Row, J.Column).Offset(0, 40).Value = Dump.Cells(i, 41).Value
RA.Cells(J.Row, J.Column).Offset(0, 41).Value = Dump.Cells(i, 42).Value
RA.Cells(J.Row, J.Column).Offset(0, 42).Value = Dump.Cells(i, 43).Value
RA.Cells(J.Row, J.Column).Offset(0, 43).Value = Dump.Cells(i, 44).Value
RA.Cells(J.Row, J.Column).Offset(0, 44).Value = Dump.Cells(i, 45).Value
RA.Cells(J.Row, J.Column).Offset(0, 45).Value = Dump.Cells(i, 46).Value
RA.Cells(J.Row, J.Column).Offset(0, 46).Value = Dump.Cells(i, 47).Value
RA.Cells(J.Row, J.Column).Offset(0, 47).Value = Dump.Cells(i, 48).Value
RA.Cells(J.Row, J.Column).Offset(0, 48).Value = Dump.Cells(i, 49).Value
RA.Cells(J.Row, J.Column).Offset(0, 49).Value = Dump.Cells(i, 50).Value
RA.Cells(J.Row, J.Column).Offset(0, 50).Value = Dump.Cells(i, 51).Value
RA.Cells(J.Row, J.Column).Offset(0, 51).Value = Dump.Cells(i, 52).Value
RA.Cells(J.Row, J.Column).Offset(0, 52).Value = Dump.Cells(i, 53).Value
RA.Cells(J.Row, J.Column).Offset(0, 53).Value = Dump.Cells(i, 54).Value
'if the customer id does not exist in RA, then look for it in Acq'
Else
Set M = Acq.Range("A:A").Find(findvalue)
'if the customer id exists in Acq then copy and paste the customer id from dump to Acq'
If Not M Is Nothing Then
Acq.Cells(M.Row, M.Column).Offset(0, 1).Value = Dump.Cells(i, 2).Value
Acq.Cells(M.Row, M.Column).Offset(0, 2).Value = Dump.Cells(i, 3).Value
Acq.Cells(M.Row, M.Column).Offset(0, 3).Value = Dump.Cells(i, 4).Value
Acq.Cells(M.Row, M.Column).Offset(0, 4).Value = Dump.Cells(i, 5).Value
Acq.Cells(M.Row, M.Column).Offset(0, 5).Value = Dump.Cells(i, 6).Value
Acq.Cells(M.Row, M.Column).Offset(0, 6).Value = Dump.Cells(i, 7).Value
Acq.Cells(M.Row, M.Column).Offset(0, 7).Value = Dump.Cells(i, 8).Value
Acq.Cells(M.Row, M.Column).Offset(0, 8).Value = Dump.Cells(i, 9).Value
Acq.Cells(M.Row, M.Column).Offset(0, 9).Value = Dump.Cells(i, 10).Value
Acq.Cells(M.Row, M.Column).Offset(0, 10).Value = Dump.Cells(i, 11).Value
Acq.Cells(M.Row, M.Column).Offset(0, 11).Value = Dump.Cells(i, 12).Value
Acq.Cells(M.Row, M.Column).Offset(0, 12).Value = Dump.Cells(i, 13).Value
Acq.Cells(M.Row, M.Column).Offset(0, 13).Value = Dump.Cells(i, 14).Value
Acq.Cells(M.Row, M.Column).Offset(0, 14).Value = Dump.Cells(i, 15).Value
Acq.Cells(M.Row, M.Column).Offset(0, 15).Value = Dump.Cells(i, 16).Value
Acq.Cells(M.Row, M.Column).Offset(0, 16).Value = Dump.Cells(i, 17).Value
Acq.Cells(M.Row, M.Column).Offset(0, 17).Value = Dump.Cells(i, 18).Value
Acq.Cells(M.Row, M.Column).Offset(0, 18).Value = Dump.Cells(i, 19).Value
Acq.Cells(M.Row, M.Column).Offset(0, 19).Value = Dump.Cells(i, 20).Value
Acq.Cells(M.Row, M.Column).Offset(0, 20).Value = Dump.Cells(i, 21).Value
Acq.Cells(M.Row, M.Column).Offset(0, 21).Value = Dump.Cells(i, 22).Value
Acq.Cells(M.Row, M.Column).Offset(0, 22).Value = Dump.Cells(i, 23).Value
Acq.Cells(M.Row, M.Column).Offset(0, 23).Value = Dump.Cells(i, 24).Value
Acq.Cells(M.Row, M.Column).Offset(0, 24).Value = Dump.Cells(i, 25).Value
Acq.Cells(M.Row, M.Column).Offset(0, 25).Value = Dump.Cells(i, 26).Value
Acq.Cells(M.Row, M.Column).Offset(0, 26).Value = Dump.Cells(i, 27).Value
Acq.Cells(M.Row, M.Column).Offset(0, 27).Value = Dump.Cells(i, 28).Value
Acq.Cells(M.Row, M.Column).Offset(0, 28).Value = Dump.Cells(i, 29).Value
Acq.Cells(M.Row, M.Column).Offset(0, 29).Value = Dump.Cells(i, 30).Value
Acq.Cells(M.Row, M.Column).Offset(0, 30).Value = Dump.Cells(i, 31).Value
Acq.Cells(M.Row, M.Column).Offset(0, 31).Value = Dump.Cells(i, 32).Value
Acq.Cells(M.Row, M.Column).Offset(0, 32).Value = Dump.Cells(i, 33).Value
Acq.Cells(M.Row, M.Column).Offset(0, 33).Value = Dump.Cells(i, 34).Value
Acq.Cells(M.Row, M.Column).Offset(0, 34).Value = Dump.Cells(i, 35).Value
Acq.Cells(M.Row, M.Column).Offset(0, 35).Value = Dump.Cells(i, 36).Value
Acq.Cells(M.Row, M.Column).Offset(0, 36).Value = Dump.Cells(i, 37).Value
Acq.Cells(M.Row, M.Column).Offset(0, 37).Value = Dump.Cells(i, 38).Value
Acq.Cells(M.Row, M.Column).Offset(0, 38).Value = Dump.Cells(i, 39).Value
Acq.Cells(M.Row, M.Column).Offset(0, 39).Value = Dump.Cells(i, 40).Value
Acq.Cells(M.Row, M.Column).Offset(0, 40).Value = Dump.Cells(i, 41).Value
Acq.Cells(M.Row, M.Column).Offset(0, 41).Value = Dump.Cells(i, 42).Value
Acq.Cells(M.Row, M.Column).Offset(0, 42).Value = Dump.Cells(i, 43).Value
Acq.Cells(M.Row, M.Column).Offset(0, 43).Value = Dump.Cells(i, 44).Value
Acq.Cells(M.Row, M.Column).Offset(0, 44).Value = Dump.Cells(i, 45).Value
Acq.Cells(M.Row, M.Column).Offset(0, 45).Value = Dump.Cells(i, 46).Value
Acq.Cells(M.Row, M.Column).Offset(0, 46).Value = Dump.Cells(i, 47).Value
Acq.Cells(M.Row, M.Column).Offset(0, 47).Value = Dump.Cells(i, 48).Value
Acq.Cells(M.Row, M.Column).Offset(0, 48).Value = Dump.Cells(i, 49).Value
Acq.Cells(M.Row, M.Column).Offset(0, 49).Value = Dump.Cells(i, 50).Value
Acq.Cells(M.Row, M.Column).Offset(0, 50).Value = Dump.Cells(i, 51).Value
Acq.Cells(M.Row, M.Column).Offset(0, 51).Value = Dump.Cells(i, 52).Value
Acq.Cells(M.Row, M.Column).Offset(0, 52).Value = Dump.Cells(i, 53).Value
Acq.Cells(M.Row, M.Column).Offset(0, 53).Value = Dump.Cells(i, 54).Value
'if the customer id doesnt exist in RA or Acq, then add it to the bottom of the list in Acq'
Else
r = Acq.Cells(Rows.Count, "A").End(xlUp).Row + 1
Acq.Cells(r, 1).Value = Dump.Cells(i, 1).Value
Acq.Cells(r, 2).Value = Dump.Cells(i, 2).Value
Acq.Cells(r, 3).Value = Dump.Cells(i, 3).Value
Acq.Cells(r, 4).Value = Dump.Cells(i, 4).Value
Acq.Cells(r, 5).Value = Dump.Cells(i, 5).Value
Acq.Cells(r, 6).Value = Dump.Cells(i, 6).Value
Acq.Cells(r, 7).Value = Dump.Cells(i, 7).Value
Acq.Cells(r, 8).Value = Dump.Cells(i, 8).Value
Acq.Cells(r, 9).Value = Dump.Cells(i, 9).Value
Acq.Cells(r, 10).Value = Dump.Cells(i, 10).Value
Acq.Cells(r, 11).Value = Dump.Cells(i, 11).Value
Acq.Cells(r, 12).Value = Dump.Cells(i, 12).Value
Acq.Cells(r, 13).Value = Dump.Cells(i, 13).Value
Acq.Cells(r, 14).Value = Dump.Cells(i, 14).Value
Acq.Cells(r, 15).Value = Dump.Cells(i, 15).Value
Acq.Cells(r, 16).Value = Dump.Cells(i, 16).Value
Acq.Cells(r, 17).Value = Dump.Cells(i, 17).Value
Acq.Cells(r, 18).Value = Dump.Cells(i, 18).Value
Acq.Cells(r, 19).Value = Dump.Cells(i, 19).Value
Acq.Cells(r, 20).Value = Dump.Cells(i, 20).Value
Acq.Cells(r, 21).Value = Dump.Cells(i, 21).Value
Acq.Cells(r, 22).Value = Dump.Cells(i, 22).Value
Acq.Cells(r, 23).Value = Dump.Cells(i, 23).Value
Acq.Cells(r, 24).Value = Dump.Cells(i, 24).Value
Acq.Cells(r, 25).Value = Dump.Cells(i, 25).Value
Acq.Cells(r, 26).Value = Dump.Cells(i, 26).Value
Acq.Cells(r, 27).Value = Dump.Cells(i, 27).Value
Acq.Cells(r, 28).Value = Dump.Cells(i, 28).Value
Acq.Cells(r, 29).Value = Dump.Cells(i, 29).Value
Acq.Cells(r, 30).Value = Dump.Cells(i, 30).Value
Acq.Cells(r, 31).Value = Dump.Cells(i, 31).Value
Acq.Cells(r, 32).Value = Dump.Cells(i, 32).Value
Acq.Cells(r, 33).Value = Dump.Cells(i, 33).Value
Acq.Cells(r, 34).Value = Dump.Cells(i, 34).Value
Acq.Cells(r, 35).Value = Dump.Cells(i, 35).Value
Acq.Cells(r, 36).Value = Dump.Cells(i, 36).Value
Acq.Cells(r, 37).Value = Dump.Cells(i, 37).Value
Acq.Cells(r, 38).Value = Dump.Cells(i, 38).Value
Acq.Cells(r, 39).Value = Dump.Cells(i, 39).Value
Acq.Cells(r, 40).Value = Dump.Cells(i, 40).Value
Acq.Cells(r, 41).Value = Dump.Cells(i, 41).Value
Acq.Cells(r, 42).Value = Dump.Cells(i, 42).Value
Acq.Cells(r, 43).Value = Dump.Cells(i, 43).Value
Acq.Cells(r, 44).Value = Dump.Cells(i, 44).Value
Acq.Cells(r, 45).Value = Dump.Cells(i, 45).Value
Acq.Cells(r, 46).Value = Dump.Cells(i, 46).Value
Acq.Cells(r, 47).Value = Dump.Cells(i, 47).Value
Acq.Cells(r, 48).Value = Dump.Cells(i, 48).Value
Acq.Cells(r, 49).Value = Dump.Cells(i, 49).Value
Acq.Cells(r, 50).Value = Dump.Cells(i, 50).Value
Acq.Cells(r, 51).Value = Dump.Cells(i, 51).Value
Acq.Cells(r, 52).Value = Dump.Cells(i, 52).Value
Acq.Cells(r, 53).Value = Dump.Cells(i, 53).Value
Acq.Cells(r, 54).Value = Dump.Cells(i, 54).Value
End If
End If
Next i
End Sub