Hi everyone, I am pretty new to VBA. Can anybody help me with my code?
I have an excel file, and sheet1 contains the source data. Please see attached
I would like to use Macro to help me copy the entire column of "PO #", and paste the entire "PO #"column to Sheet2's cell A1.. The position of "PO #" may vary. It may not be at Column C, so I need to ask Macro to help me locate that column
Here is the code I wrote but it doesn't work.. It only copies the column where my mouse is at... not sure what is wrong
Sub Macro1()
Dim j As Long
For j = 1 To 8
Sheets("Sheet1").Activate
If Sheets("Sheet1").Cells(j, 1) = "PO #" Then Sheets("Sheet1").Cells(j, 1).Select
Selection.EntireColumn.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next j
End Sub
I have an excel file, and sheet1 contains the source data. Please see attached
I would like to use Macro to help me copy the entire column of "PO #", and paste the entire "PO #"column to Sheet2's cell A1.. The position of "PO #" may vary. It may not be at Column C, so I need to ask Macro to help me locate that column
Here is the code I wrote but it doesn't work.. It only copies the column where my mouse is at... not sure what is wrong
Sub Macro1()
Dim j As Long
For j = 1 To 8
Sheets("Sheet1").Activate
If Sheets("Sheet1").Cells(j, 1) = "PO #" Then Sheets("Sheet1").Cells(j, 1).Select
Selection.EntireColumn.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next j
End Sub