Using a Macro to copy information from one sheet to another

April 13, 2012 at 12:01:42
Specs: Windows 7
i have a spreadsheet that is looking up data from a daily update sheet, and I need to, if a column contains a particular piece of information, copy some info from one sheet to the next. The pertinent columns are thus:

Sheet 1 (source, sheet is named "Import")

         Index         Serial Number
1       induct        x10001
2       1               x10002
3       2               x10003
4       induct        x10004

Sheet 2(destination, Sheet is named "Primary")

         Serial Number
1        x10002
2        x10003

The macro would need to step through the Import tab checking each row (starting at 2, row one has the row headers) and copy cell 2(the serial number) on any row where cell 1 contains the word "Induct" and paste it in to column 1 of the primary tab in the first empty cell.

See More: Using a Macro to copy information from one sheet to another

April 16, 2012 at 09:49:34
Currently this is what I have, but its not working. It copies the data but does not paste it in to the appropriate cell(doesn't paste anything anywhere, as near as I can tell. )

Sub Induct()
'start at row 2. Row 1 has headers
x = 2
'Start the loop
Do While Cells(x, 1) <> ""
'Look for data with 'induct'
If Cells(x, 1) = "Induct" Then
'copy the Cell if it contains 'Induct'
Worksheets("Import").Cells(x, 2).Copy
'Go to sheet2. Activate it. We want the data here
'Find the first empty row in sheet2
erow = Sheets("Primary").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Row
'Paste the data here
ActiveSheet.Paste Destination:=Worksheets("Primary").Cells(erow, 1)
End If
'go to sheet1 again and actvate it
'Loop through the other rows with data
x = x + 1

End Sub

Report •
Related Solutions

Ask Question