Copy Rows to Existing Worksheets

H

HamishM

Hi,

I need to copy a number of rows from a master worksheet to existin
worksheets within the same work book.

Ideally i would like to check the values of one column and send tha
row to the corresponding worksheet based on the result.

e.g.

check row 1 and if Value in Column H = Blue,
send entire row to worksheet 'Blue'.

repeat for all rows in master sheet.

Hope i am making sense and that someone can help.

thanks,
Hamis
 
D

Don Guillett

how about something like
Sub copyblue()
For Each c In Range("e2:e22")
If UCase(c) = "B" Then
x = Sheets("sheet4").Cells(Rows.Count, "a") _
..End(xlUp).Row + 1
c.EntireRow.Copy Sheets("Sheet4").Cells(x, "a")
End If
Next
End Sub
 
H

HamishM

Thanks Don.

I'm quite new to VBA so could you explain what each of the lines ar
doing and the variables?

Appreciate your help
Hamis
 
D

Don Guillett

Macro is looking for cells that contain "b" or "B" in the range and copying
the row to next available row on sheet 4 in col A.
The line with the space & underscore ( _ ) is a "continuation" character to
make the line into one line.

Sub copyblue()
For Each c In Range("e2:e22")
If UCase(c) = "B" Then
x = Sheets("sheet4").Cells(Rows.Count, "a") _
..End(xlUp).Row + 1
c.EntireRow.Copy Sheets("Sheet4").Cells(x, "a")
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