ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy and paste from one tab to another with certain rules using VBA (https://www.excelbanter.com/excel-programming/448609-copy-paste-one-tab-another-certain-rules-using-vba.html)

missexcel12

Copy and paste from one tab to another with certain rules using VBA
 
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.

Claus Busch

Copy and paste from one tab to another with certain rules using VBA
 
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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

missexcel12

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



Quote:

Originally Posted by Claus Busch (Post 1611269)
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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


Claus Busch

Copy and paste from one tab to another with certain rules using VBA
 
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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com