VBA copy sheet 1 to Array and put relevant information on sheet 2

Peteor

Board Regular
Joined
Mar 16, 2018
Messages
152
Hello! I have a worksheet where Columns A:Z are used. I would like to take all rows on sheet 1 where Column E has a value of "2" AND Column J has a value of "Example", and copy the information from the Entire Row to sheet 2. Row 1 on sheet 1 is just header information. I would also like this on sheet 2.

I recognize this to be a very broad question, and believe this to be done with "CreateObject("scripting.dictionary")"... I would like to understand how to use this class on my own, but am struggling. Any comments would be greatly appreciated...
 

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.
The simplest way of doing that would be with an autofilter
Code:
Sub Peteor()
   
   With Sheets("Sheet1")
      .Range("A1:Z1").AutoFilter 5, 2
      .Range("A1:Z1").AutoFilter 10, "Example"
      .AutoFilter.Range.Copy Sheets("sheet2").Range("A1")
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
The following does not work, but I would like it to:

.Range("A1:Z1000").AutoFilter Field:=5, Criteria1:="3", Operator:=xlAnd, Criteria2:="4", Operator:=xlAnd, Criteria3:="5"
.Range("A1:Z1000").AutoFilter 10, "Example"

I would like to filter off all possibilities (Integers 1 - 7) except Criteria 1-3 listed above, and then execute the next line.

What would you advise here?
 
Upvote 0
Try
Code:
      .Range("A1:Z1").AutoFilter 5, Array(3, 4, 5), xlFilterValues
 
Upvote 0
I ran it and it did not work. I stepped through it, and when it ran the line you provided, none of the filter criteria were checked. The issue is not an error, so the .AutoFilter.Range.Copy (next line) copys a blank sheet.
 
Upvote 0
It should be
Code:
      .Range("A1:Z1").AutoFilter 19, Array("3", "4", "5"), xlFilterValues
Keep forgetting to put them as strings
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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