Copy and paste from one tab to another with certain rules using VBA

M

missexcel12

Hi. I need a code that does the following please. Copy and pastes a ro
from tab 1 (“April”) to tab 2 (“May”). However if there’s a ‘0’ i
column H then I only want it to paste the row from column B onwards. I
there’s a ‘1’ in column H, I need it to copy and paste the entire row
I’d also like it to paste in the row same on the 2nd tab. For example i
its in row 5 on tab 1 I’d like it to appear in row 5 on tab 2. I’d lik
it also to appear automatically in the 2nd tab after inputting th
number 0 or 1 into the column H. Hope this all makes sense
 
C

Claus Busch

Hi,

Am Tue, 16 Apr 2013 16:20:29 +0100 schrieb missexcel12:
Hi. I need a code that does the following please. Copy and pastes a row
from tab 1 (“April”) to tab 2 (“May”). However if there’s a ‘0’ in
column H then I only want it to paste the row from column B onwards. If
there’s a ‘1’ in column H, I need it to copy and paste the entire row.
I’d also like it to paste in the row same on the 2nd tab. For example if
its in row 5 on tab 1 I’d like it to appear in row 5 on tab 2. I’d like
it also to appear automatically in the 2nd tab after inputting the
number 0 or 1 into the column H. Hope this all makes sense.

copy the sheet and name the copy "May". And then delete the cells in A
if in H is 0


Regards
Claus Busch
 
M

missexcel12

Hi. Thanks for this. Unfortunately I need a code to complete thi
automatically as the tabs are already set up with other formulas.
 
C

Claus Busch

Hi,

Am Wed, 17 Apr 2013 09:58:41 +0100 schrieb missexcel12:
Hi. Thanks for this. Unfortunately I need a code to complete this
automatically as the tabs are already set up with other formulas.

try:

Sub CopyAndDelete()
Dim LRow As Long

Sheets("April").Copy After:=Sheets("April")
With ActiveSheet
.Name = "Mai"
LRow = .Cells(.Rows.Count, "H").End(xlUp).Row
.Range("A1:H" & LRow).AutoFilter Field:=8, Criteria1:=0
.Range("A2:A" & LRow).ClearContents
.AutoFilterMode = False
End With
End Sub


Regards
Claus Busch
 

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