Copy Autofiltered values from one sheet to another stopping at one column.

JasonWilliam

New Member
Joined
May 11, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I presently have a code that copies all rows from one sheet (named BOM) to the next available row on another sheet (named BOM Data). I would like to autofilter the data on the BOM sheet to only copy the rows STOPPING on row that contain the word "Laser". So far this is my code.

Private Sub CommandButton1_Click()

With Range("A4:I" & Range("A" & Rows.Count).End(xlUp).Row)
.AutoFilter field:=9, Criteria1:="Laser"
Sheets("BOM Data").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
End Sub

The problem I am having is it might filter the data correctly but it still copies all rows that have data in them even if they do not contain laser in them. Also I would like the autofilter to shut off afterwards so I do not have to it manually.

Thank you.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try:

VBA Code:
Sub jec()
 Application.ScreenUpdating = False
 With Range("A4:I" & Range("A" & Rows.Count).End(xlUp).Row)
   .AutoFilter 9, "Laser"
   .Offset(1).Copy
    Sheets("BOM Data").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
   .AutoFilter
 End With
End Sub
 
Upvote 0
Solution
That worked! Thank you, I've been trying for about a day to figure this out...lol
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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