View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul Mathews Paul Mathews is offline
external usenet poster
 
Posts: 84
Default copy and paste from one sheet to another with VBA

One way to do this in code (assuming I understood your post correctly) would
be something along the lines of:

Sub CopyRedBlue()
'Copies entire rows from Books sheet to Tapes sheet only where cell in
column A contains the value "Red" and cell in column B contains the value
"Blue"
Application.ScreenUpdating = False
Sheets("Books").Select
Range("A1").Select
Sheets("Tapes").Select
Range("A1").Select
Do Until ActiveCell.Value = ""
If VBA.UCase(ActiveCell.Value) = "RED" And
VBA.UCase(ActiveCell.Offset(0, 1).Value) = "BLUE" Then
ActiveCell.EntireRow.Copy
Sheets("Tapes").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Select
Sheets("Books").Select
ActiveCell.Offset(1, 0).Select
Application.CutCopyMode = False
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Application.ScreenUpdating = True
End Sub

Another possibility might be to just apply an Auto Filter on your "Books"
sheet and then just filter column A to see only "Red" items and column B to
see only "B" items. No code required on that approach.

"SITCFanTN" wrote:

I've scanned the posts and I can't seem to find what I'm looking for, many of
the posts talks about numerous workbooks, I'm just trying to query Sheet 1
and make mini reports on the subsequent sheets.

For instance if I want to copy and paste all rows with "Red" in Column A and
"Blue" in column B from sheet 1 titled "Books" to sheet 2 titled "Tapes", is
there simple code that will accompish that with an existing macro? I would
run the macro from sheet 1 each day.

Thanks