Extract Data to another Column

hoodielive

New Member
Joined
Apr 27, 2014
Messages
5
Is there a way to extract all values starting with aa, pt, ra or whatever multiple values starting with defined prefixes into another column.

So if
aa12345
as12345
root
sys
aa90231

are in column a
I would like to move them into column F or possibly another worksheet.
But I would need to extract the entire row or by columns ??

I would also have to be able to pass multiple parameters into the code -- such as aa, ab, ac and it's proceeding numbers. I hope this clear.

Please Help
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
hi

assuming data starts from a1 , use the below autofilter option to do the rest of the action after filtered
ActiveSheet.Range("$A$1).AutoFilter Field:=1, Criteria1:="=aa*", Operator:=xlAnd
 
Upvote 0
First of all, I would like to express my gratitude to you sriram170. I can not begin to tell you how hard I've been working to automate certain processes at my job. The other part of this response is to seek clarity as I am getting an error when I run the code. It says it expected a ) or separator. Also, I will be using multiple prefixes, not just aa. So in that part where the criteria =aa* do I also put & =ab* & =fa*? Thank you for your kindness and your willingness to help me on this.
 
Upvote 0
then u should use for loop in a particular range then give the criteria with each cell in range to filter
 
Upvote 0
How? This is why I posted the question. I am a beginner at VBA. I've watched so many tutorials but it is not clicking.
 
Upvote 0
Option Base 1
Option Explicit
Sub cleansewithArrays()

Dim filter() As Variant
' filter is the array with the prefixes I will need to autofilter
' What I want to remain is only values with the following prefixes
filter = Array( _
"fe*", "ff*", "fw*", "ll*", "pg*", "ph*", "pm*", "pp*" _
, "pt*", "xx*", "zx*")
ActiveSheet.Range("A:A").AutoFilter _
Field:=1, Criteria1:=Array(filter), Operator:=xlOr ' xlFilterValues

End Sub


Here's what I came up with. However it only filters the last criteria : zx. What am I doing wrong?
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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