1 Create a macro to Copy & paste certain data to another sheet

L

Lin1981

I have no experience with macros @ all. Really need your help.
I have a spreedsheet that I sort by column A, depending on what code is in
column A, I need the data adjacent to it copied to another sheet.


Example: SHEET "OPEN"
COLUMN A COLUMN B COLUMN C COLUMN D
09 $25,000 ABC VENDOR 11/2/08
13 $55.00 XYZ VENDOR 10/19/08

IF COLUMN A ON WORKSHEET "OPEN" IS = 09 THEN I NEED EVERYTHING IN THE ROW
ADJACENT TO IT (COLUMN B THRU D) COPIED TO SHEET "SMITH". CAN ANYONE HELP ME.
 
S

Sheeloo

I wrote a similar macro yesterday for another post..

Open the workbook
Press ALT-11 to open VB Editor
Click on your workbook name on the left
Click on Insert->Module
Paste the code below
Press the PLAY button on the top

Go to your workbook and verify

Sub copyit()
'IF COLUMN A ON WORKSHEET "OPEN" IS = 09 THEN I NEED EVERYTHING IN THE ROW
'ADJACENT TO IT (COLUMN B THRU D) COPIED TO SHEET "SMITH".

Dim shName As String
Dim MyRange As Range
Dim sh As Worksheet

Set MyRange = Worksheets("Open").Range("A1:A" &
Worksheets("Open").Cells(Rows.Count, "A").End(xlUp).Row)

For Each c In MyRange
'If Col A contains numbers then replace "09" with 9 below
If c.Value = "09" Then

c.EntireRow.Copy _
Destination:=Sheets("Smith").Cells(Sheets("Smith").Cells(Rows.Count,
"A").End(xlUp).Row + 1, 1)
End If

Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top