Copy row over to new sheet based on cell value

megaco

New Member
Joined
Mar 12, 2019
Messages
4
I am working on an excel worksheet where I need a macro that will copy the entire row (A-K) to a new sheet when column A contains the following values:

CCKE
CSUL
SOLV
SPCK
SVCA
SVMX
GSPP

<colgroup><col></colgroup><tbody>
</tbody>

Would appreciate any help!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try:
Code:
Sub test()
    Dim Ary As Variant
    Ary = Array("CCKE", "CSUL", "SOLV", "SPCK", "SVCA", "SVMX", "GSPP")
    With Range("A1").CurrentRegion
       .Range("A1:K1").AutoFilter 1, Ary, xlFilterValues
       .Offset(1, 0).SpecialCells(xlCellTypeVisible).Copy Sheets("Sheet2").Range("A" & Sheets("Sheet2").Rows.Count).End(xlUp).Offset(1, 0)
       .AutoFilter
    End With
End Sub
 
Upvote 0
I am working on an excel worksheet where I need a macro that will copy the entire row (A-K) to a new sheet when column A contains the following values:

CCKE
CSUL
SOLV
SPCK
SVCA
SVMX
GSPP

<tbody>
</tbody>

Would appreciate any help!

Thank you so much! this worked!
 
Upvote 0
I was wonder if I get could some help with one additional problem.

I need this macro to add a second sheet first so that it has somewhere to move the information.

Additionally, is there any way to have this apply regardless of the sheet name? Just based on the fact the it is the first and second sheet in the document?

Thanks in advance!!
 
Upvote 0
This macro will create a new sheet named "Result" before copying the data to it. Change the name (in red) in the macro to suit your needs.
Code:
Sub test()
    Dim Ary As Variant
    Ary = Array("CCKE", "CSUL", "SOLV", "SPCK", "SVCA", "SVMX", "GSPP")
    With Range("A1").CurrentRegion
       .Range("A1:K1").AutoFilter 11, Ary, xlFilterValues
       .Offset(1, 0).SpecialCells(xlCellTypeVisible).Copy
       Worksheets.Add(After:=Sheets(Sheets.Count)).Name = "[COLOR="#FF0000"]Result[/COLOR]"
       Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
       .AutoFilter
    End With
    Application.CutCopyMode = False
End Sub
 
Upvote 0
I'm looking to move a row from one sheet to another sheet when a value in row H is changed to "closed" can I get help with this.
 
Upvote 0
@jwilliamson: Welcome to the Forum. :) According to Forum rules, you should not post your question in another member's thread. Please start your own new thread explaining in detail what you want to do. Include a link to this thread if you feel it is helpful. If you send me a private message with a link to your new thread, I'll be happy to have a look at it.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top