View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Sheeloo[_3_] Sheeloo[_3_] is offline
external usenet poster
 
Posts: 1,805
Default 1 Create a macro to Copy & paste certain data to another sheet

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

"Lin1981" wrote:

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.