Search Code Confusing me please help :)

Krucifire

Board Regular
Joined
Nov 8, 2007
Messages
96
Book1.xls
QRSTUVWX
1ACTNSWNTQLDSATASVICWA
2
3BelconnenAlburyDarwinAlbionAllenbyGardensLauncestonAltonaAlbany
4FyshwickArtarmonPalmerstonBoovalKentTownMoonahBallaratBalcatta
5TuggeranongAshfieldBrownsPlainsMarionRosnyParkBayswaterBelmont
6AuburnBundabergMileEndBendigoBibraLake
7BallinaBurleighHeadsModburyBoxHillBunbury
8BankstownAirportCairnsMtGambierBroadmeadowsBusselton
9BatemansBayCaloundraMunnoParaCoburgCannington
10BathurstCannonHillNoarlungaCorioClaremont
11BelmontCapalabaParafieldCranbourneEsperance
12BelroseCarseldineWindsorGardensCroydonGeraldton
13BlacktownComptonRd,UnderwoodDandenongHomebase
14BonnyriggGladstoneElthamInglewood
15CampbelltownHarbourtownEppingInnaloo
16CardiffHerveyBayFountainGateJoondalup
17CaringbahLawntonFrankstonKalamunda
18CarlingfordMackayHoppersCrossingKalgoorlie
19CessnockMaroochydoreKeysboroughMaddington
20ChatswoodMorayfieldMaribyrnongMalaga
21CoffsHarbourSouthMtGravattMeltonMandurah
22CoffsHarbourTradeMtIsaMentoneMelville
23CrossroadsNerangMilduraMidland
24DuralNoosavilleMillParkMindarie
25ErinaNorthOxleyMoorabbinMorley
26ForsterRockhamptonMorningtonO'Connor
27GlendaleRockleaMorwellPortKennedy
28GordonRothwellNorthlandRockingham
29GosfordSouthportNottingHillSouthPerth
30GraftonStaffordNunawadingWhitfords
31GriffithToowoombaWestPortMelbourneWilletton
32KempseyNorthTownsvilleRosebud
33KempseySouthUnderwoodSandown
34KotaraVictoriaPointScoresby
35LakeHavenWarwickShepparton
36LidcombeSouthOakleigh
37LismoreSunbury
38MaitlandSunshine
39MascotTaylorsLakes
40McGrathsHillThomastown
41MinchinburyVermontSouth
42MossValeWarrnambool
43MudgeeWaurnPonds
44NarrabeenWodonga
45NelsonBayWodongaNorth
46NorthParramatta
47NorthPenrith
48Norwest
49Nowra
50Orange
51Penrith
52PortMacquarie
53Rockdale
54RoseBay
55SevenHills
56ShellHarbour
57Tamworth
58Taree
59Thornleigh
60Tuggerah
61TweedHeads
62Ulladulla
63Unanderra
64ValleyHeights
65Villawood
66WaggaWagga
67Warrawong
68WarringahMall
69Wollongong
Sheet1




Above is a sample of data, from a spread sheet where im working with a macro i found on the formus here,


Code:
'============================================
'- FIND RECORDS IN A DATA TABLE
'- AND PUT INTO A SUMMARY SHEET
'- needs a sheet called "Summary"
'- change "DataSheet" to lookup sheet name
'- Brian Baulsom February 2005
'=============================================
'-
Sub FindRecords()
    Dim FromSheet As Worksheet
    Dim FromRow As Long
    Dim ToSheet As Worksheet
    Dim ToRow As Long
    Dim FindThis As Variant
    Dim FoundCell As Object
    '---------------------------------------------------
    Application.Calculation = xlCalculationManual
    Set FromSheet = ThisWorkbook.Worksheets("DataSheet")
    Set ToSheet = ThisWorkbook.Worksheets("Summary")
    ToRow = 2
    '---------------------------------------------------
    '- get user input
    FindThis = InputBox("Please enter data to find : ")
    If FindThis = "" Then End ' trap Cancel
    '---------------------------------------------------
    '- clear summary for new data
    ToSheet.Cells.ClearContents
    '---------------------------------------------------
    ' FIND DATA
    '-
    With FromSheet.Cells
        Set FoundCell = .Find(FindThis, LookIn:=xlValues)
        If Not FoundCell Is Nothing Then
            FirstAddress = FoundCell.Address
            '------------------------------------------
            '- copy data to summary
            Do
                FromRow = FoundCell.Row
                ToSheet.Cells(ToRow, 1).Value = _
                        FromSheet.Cells(FromRow, 1).Value
                ToSheet.Cells(ToRow, 2).Value = _
                        FromSheet.Cells(FromRow, 2).Value
                ToSheet.Cells(ToRow, 3).Value = _
                        FromSheet.Cells(FromRow, 3).Value
                ToRow = ToRow + 1
                Set FoundCell = .FindNext(FoundCell)
            Loop While Not FoundCell Is Nothing And _
                FoundCell.Address<> FirstAddress
            '------------------------------------------
        End If
    End With
    MsgBox ("Done.")
    Application.Calculation = xlCalculationAutomatic
End Sub

this code is a little beyond what i know how to do so before i started chopping and changing the code i thought i would check here for advice on how i do it.


is what i need is for when the person enters in one of the store names from the list above, for it to display data stored in columns B, D and P. The columns it will need to search in for the specific store name are Q through to X (as shown in the spread sheet above) however

the data is store as follows (cell references below are Column:Row)

(Q:A1)Belconnen, #fyshwick
(W:A1)Boxhill, #Nunawading, #Coburg


hope i explained that clear enough for you guys to help :)

Regards

- Troy
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Just an Update,

Ive got this macro displaying the data from the correct columns i need, But the its find incorrect Data

Im not too sure how the actual search parameters are being set, but for example if I search the word Box,

The only word with in the whole spread sheet that will match this search will be the store name Boxhill, how it returned data where this was not contained. If i Search Boxhill, it returns nothing

any ideas ???
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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