Im somewhat of a novice at Excel VBA. Im trying to create a sub routine that copies the contents from a cell Sheet1 A2 and pastes to cell Sheet2 A2, the latter being specified in cell Sheet 1 B1. Simple expample.
Sheet1 A2 = 100
Sheet1 B1 = Sheet2 A2
I need help with the code that looks at the cell Sheet1 B1 for the location "Sheet2 A2" to paste the value 100 into?
My curent code is:
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