ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If value is then copy (https://www.excelbanter.com/excel-worksheet-functions/205711-if-value-then-copy.html)

Carolina Girl

If value is then copy
 
Can someone can help me??? I need a VBA code that will say€¦
if value of cell A2 is equal to €œx€ then copy G2:P2 to worksheet €œtest2€
if value of cell B2 is equal to €œx€ then copy G2:P2 to worksheet €œtest3€
etc...
if value of cell A3 is equal to €œx€ then copy G3:P3 to worksheet €œtest2€
if value of cell B3 is equal to €œx€ then copy G3:P3to worksheet €œtest3€
etc...
There has to be a faster way??? I have 6 items to check across and 350
down (more will be added. Please note row 2 may have an x in A2 and B2 but
row 3 may only have an x in B3..... Thank you in advance


Don Guillett

If value is then copy
 

Have a look in the vba help index for select case and incorporate into a
for/each loop.
You don't say where in test2 to copy to

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Carolina Girl" wrote in message
...
Can someone can help me??? I need a VBA code that will say€¦
if value of cell A2 is equal to €œx€ then copy G2:P2 to worksheet €œtest2€
if value of cell B2 is equal to €œx€ then copy G2:P2 to worksheet €œtest3€
etc...
if value of cell A3 is equal to €œx€ then copy G3:P3 to worksheet €œtest2€
if value of cell B3 is equal to €œx€ then copy G3:P3to worksheet €œtest3€
etc...
There has to be a faster way??? I have 6 items to check across and 350
down (more will be added. Please note row 2 may have an x in A2 and B2 but
row 3 may only have an x in B3..... Thank you in advance



Carolina Girl

If value is then copy
 
no have not looked but will... As for where in worksheet "test2" all 6
worksheets are set up with the same header row so it should past in the first
empty row starting on A2.
Thanks in advance....


"Don Guillett" wrote:


Have a look in the vba help index for select case and incorporate into a
for/each loop.
You don't say where in test2 to copy to

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Carolina Girl" wrote in message
...
Can someone can help me??? I need a VBA code that will say€¦
if value of cell A2 is equal to €œx€ then copy G2:P2 to worksheet €œtest2€
if value of cell B2 is equal to €œx€ then copy G2:P2 to worksheet €œtest3€
etc...
if value of cell A3 is equal to €œx€ then copy G3:P3 to worksheet €œtest2€
if value of cell B3 is equal to €œx€ then copy G3:P3to worksheet €œtest3€
etc...
There has to be a faster way??? I have 6 items to check across and 350
down (more will be added. Please note row 2 may have an x in A2 and B2 but
row 3 may only have an x in B3..... Thank you in advance





All times are GMT +1. The time now is 08:59 AM.

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