Я немного новичок в Excel VBA.Я пытаюсь создать подпрограмму, которая копирует содержимое из ячейки Sheet1 A2 и вставляет в ячейку Sheet2 A2, последняя указана в ячейке Sheet 1 B1.Простой пример.
Sheet1 A2 = 100
Sheet1 B1 = Sheet2 A2
Мне нужна помощь с кодом, который просматривает ячейку Sheet1 B1 для местоположения "Sheet2 A2", чтобы вставить значение 100 в?
Мой текущий код:
Sub CopyRows()
Sheets("Sheet1").Select
' Find the last row of data
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
' Loop through each row
For x = 1 To FinalRow
' Decide if to copy based on column D
ThisValue = Cells(x, 4).Value
If ThisValue = "A" Then
'Cells(x, 1).Resize(1, 33).Copy
Cells(x, 1).Resize(1, 1).Copy
Sheets("SheetA").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
ElseIf ThisValue = "B" Then
Cells(x, 1).Resize(1, 1).Copy
Sheets("SheetB").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
End If
Next x
End Sub