josros60

Well-known Member
Joined
Jun 27, 2010
Messages
781
Office Version
  1. 365
Hi,


i have this huge spreasheet (attached) that i want to search for records and put the results temporary an new sheet but i am not good in vba, can any body help.


CARRIERACCOUNT NUMBERACCOUNT NAMEBTNWTNAUTH_CODEAUTH.CODE.STATUS
BCTEL000071411CENTURY 21 MOVING REAL ESTATE BC LTD250378434400000000002503784344Active
BCTEL000000021CN (IT TELECOM)250459791800000000002504597918Active
BCTEL000000021CN (IT TELECOM)250459792800000000002504597928Active
BCTEL000110709GLOBAL PARTNERS INSTITUTE604448425000000000006044484250Active
BCTEL000076963GEORGE RICHARD LOW250577375800000000002505773758Active
BCTEL000110024ROYAL LEPAGE LOCATIONS WEST REALTY250493758700000000002504937587Active
BCTEL000151077VILLAGE OF PORT ALICE250284339200000000002502843392Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770131700000000002507701317Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860100000000002507708601Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860200000000002507708602Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770915700000000002507709157Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770131700000000002507701317Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860100000000002507708601Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860200000000002507708602Active
BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770915700000000002507709157Active
BCTEL000074693HOMELIFE GLENAYRE REALTY CO LTD604462735900000000006044627359Active
BCTEL000163771IKTEROS ENTERPRISES INC604448879000000000006044488790Active
TELUS000164717BANCORP FINANCIAL SERVICES INC604608271700000000006046082717Active
TELUS000158736ESKIMO STEEL403468091000000000004034680910Active
TELUS000158775ASA ALLOYS INC EDMONTON403417054200000000004034170542Active
TELUS000158736ESKIMO STEEL403468090900000000004034680909Active
TELUS000158736ESKIMO STEEL403468173600000000004034681736Active
TELUS000158775ASA ALLOYS INC EDMONTON403417051300000000004034170513Active
TELUS000158775ASA ALLOYS INC EDMONTON403417051400000000004034170514Active
TELUS000158775ASA ALLOYS INC EDMONTON403417051500000000004034170515Active
TELUS000158775ASA ALLOYS INC EDMONTON403417051600000000004034170516Active
TELUS000158775ASA ALLOYS INC EDMONTON403417051700000000004034170517Active
TELUS000158775ASA ALLOYS INC EDMONTON403417056400000000004034170564Active
TELUS000158736ESKIMO STEEL403463970400000000004034639704Active
BCTEL000171397STERLING GROUP CORP604850129900000000006048501299Active
BCTEL000061435CONSULATE GENERAL OF JAPAN604685589500000000006046855895Active
BCTEL000095108TIDE RIP TOURS LTD.250928309200000000002509283092Active

<tbody>
</tbody>

<tbody>
</tbody>



thank you
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
What criteria do you want to use to search for the records? For example, do you want to search by Account Number, Account Name, etc.? If there is more than one occurrence of the search criteria, do you want to copy all the occurrences or just the first one?
 
Upvote 0
thank you for responding.

i want to search by AUTH_CODE.

thanks again
 
Upvote 0
Copy the range to a variant array and then filter by Auth_Code...

Actually that won't work right, scratch that.

How many rows is huge, btw? This might be a perfect spot to use a binary search algorithm on a variant array.

Are the auth_codes all different?

Are you looking for multiple ones at a time?

Could also use autofilter and pass in an array. Need to know more about how exactly you want this to work tho. I have passed in an array of 623 values on a 203,000 row record set and it filtered it pretty quickly...
 
Last edited:
Upvote 0
This macro will prompt you to enter a AUTH CODE. If found (assuming it is in column D and that there are no duplicate codes), that row will be copied to Sheet2.
Code:
Sub AuthCODE()
    Application.ScreenUpdating = False
    Dim foundAC As Range
    Dim response As String
    response = InputBox("Please enter the AUH CODE.")
    Set foundAC = Range("D:D").Find(response, LookIn:=xlValues, lookat:=xlWhole)
    If Not foundAC Is Nothing Then
        foundAC.EntireRow.Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Else
        MsgBox (response & " not found.")
    End If
    Application.ScreenUpdating = True
End Sub
If there can be duplicate codes, let me know and I will modify the macro to account for that.
 
Last edited:
Upvote 0
thank you.


actually the auth_codes is will be link to this TSCI_CODE


whihc means that for example in the list 2503484444 can have two or more TSCI_CODE codes, like 2004, 2002 etc.


what i want is when search put the resuls auth_coes with the differetns TSCI_CODE.




here the table i missed the first column previously.

TSCI_CODEDIRECTIONCARRIERACCOUNT NUMBERACCOUNT NAMEBTNWTNAUTH_CODEAUTH.CODE.STATUSACCT STATUS
21042BCTEL000071411CENTURY 21 MOVING REAL ESTATE BC LTD250378434400000000002503784344ActiveA
21042BCTEL000000021CN (IT TELECOM)250459791800000000002504597918ActiveA
21042BCTEL000000021CN (IT TELECOM)250459792800000000002504597928ActiveA
21042BCTEL000110709GLOBAL PARTNERS INSTITUTE604448425000000000006044484250ActiveA
21042BCTEL000076963GEORGE RICHARD LOW250577375800000000002505773758ActiveA
21042BCTEL000110024ROYAL LEPAGE LOCATIONS WEST REALTY250493758700000000002504937587ActiveA
21042BCTEL000151077VILLAGE OF PORT ALICE250284339200000000002502843392ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770131700000000002507701317ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860100000000002507708601ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860200000000002507708602ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770915700000000002507709157ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770131700000000002507701317ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860100000000002507708601ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770860200000000002507708602ActiveA
21042BCTEL000105151ABC ALLEN BUSINESS COMMUNICATIONS250770915700000000002507709157ActiveA
21042BCTEL000074693HOMELIFE GLENAYRE REALTY CO LTD604462735900000000006044627359ActiveA

<colgroup><col span="3"><col><col><col span="3"><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
I'm not sure what you mean when you say
the auth_codes is will be link to this TSCI_CODE
Please clarify. What do you mean by "link"?
Also you say
2503484444 can have two or more TSCI_CODE codes, like 2004, 2002
I don't see these values on the data you posted so it's difficult to see the relationship between the AUTH_CODE and the TSCI_CODE codes.
 
Upvote 0
How are you determining which auth_codes to search? So you have them listed on a separate sheet? Enter them in somewhere?

This seems like a perfect case to just autofilter by an array and then copy the autofilter range but I need to know more to set it up properly.
 
Upvote 0
hi,

the code sample vba posted above works but only give me one record and what i want is that when i enter the auth_codes 2503214488 to give all the records related to that number because that number can be repeated with different TSCI_CODE codes hence the result will be same auth_codes with different tsci_codes. i know the list i posted have the same tsci_code 2104 but the complete list have lots of different ones.

thank you


 
Upvote 0
hi,

the code sample vba posted above works but only give me one record and what i want is that when i enter the auth_codes 2503214488 to give all the records related to that number because that number can be repeated with different TSCI_CODE codes hence the result will be same auth_codes with different tsci_codes. i know the list i posted have the same tsci_code 2104 but the complete list have lots of different ones.

thank you



Where are these records coming from? Ill build you an autofilter function but I need to know how you are getting which auth code to look up
 
Upvote 0

Forum statistics

Threads
1,215,235
Messages
6,123,779
Members
449,123
Latest member
StorageQueen24

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