Avatar of upobDaPlaya
upobDaPlaya
 asked on

Excel VBA - Creating a recordset that is filtered

I have a tab called Source.  Within VBA I currently have

Set wsSource = Sheets("Source")
x = wsSource.Range("A1").CurrentRegion.Value

For i = 2 to Ubound(x,1)
......
........

The issue is I now realize that I should only be running the above code (just a sample above) if the records in the source tab are approved.  There is a field called Approved where user put yes/no.  Thus, how do I change my code so that x reflects only Approved records.  I assume I need to create a recordset for x ?
VBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
upobDaPlaya

8/22/2022 - Mon
Shums Faruk

Hi,

Please upload your sample workbook or full code.
David L. Hansen

I'd use a VLookUP function to grab what's in column A based on what the value is in your "Approved" column.
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
I'd use "yes" or "no" as the lookup_value, and your approval column as the range.
A good example is here.

You may be able to do all of what you need with out any vba code at all.
Norie

You could apply a filter to only return the 'records', ie rows, that have 'Yes' in the 'Approved field', ie column.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Wayne Taylor (webtubbs)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
upobDaPlaya

ASKER
Perfect...thx