There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Excel Lookup a special title


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
xwusa's Avatar
Junior Member with 1 posts.
 
Join Date: Aug 2007
Experience: Advanced
09-Aug-2007, 04:42 PM #1
Excel Lookup a special title
Hello Excel Expert,

Here is a scenario in an Excel programming I need help to resolve. There is a big data table as the following:

Column 1 ==== Column 2 ==== Column 3 ==== Column 4
*Data 11 ===== *Data 12 ==== *Data 13 ==== *Data 14
Data 21 ====== Data 22 ===== Data 23 ===== Data 24
Data 31 ====== Data 32 ===== Data 33 ===== Data 34
Data 41 ===== *Data 42 ===== *Data 43 ===== Data 44
*Data 51 ====== Data 52 ===== *Data 53 ==== *Data 54
Data 61 ====== Data 62 ===== Data 63 ===== Data 64
*Data 71 ===== *Data 72 ===== Data 73 ===== Data 74
Data 81 ====== Data 82 ===== Data 83 ===== Data 84

Conditions:
1. The data started with a special character, *, defines its group for the rest of the data in its column until it hits another *, which is the stat point of the next group.

For example, the groups are as the following:
Group 1: Data 11, Data 21, Data 31, Data 41,
Group 2: Data 51, Data 61
Group 3: Data 71, Data 81
Group 4: Data 12, Data 22, Data 32
Group 5: Data 42, Data 52, Data 62
Group x: ……..

2. The table is big. It contains any number of group ID, *, and any members within a group (the minimum is one). The table can be updated with new data randomly for both addition and/or deletion.

The objective:
When a user inputs a data ID (for example: “Data 32”), the excel needs to find out the first member in its group (such as "Data 12" in this example).

Due to the large table, use a manual process, such as GUI-based define names, may not be practicable. We have to find out a way for automatically programmable solution.

Looking forward to your help.

Best regards,

Wei
StripedMeow's Avatar
Computer Specs
Junior Member with 5 posts.
 
Join Date: Aug 2007
Location: CA
Experience: Intermediate
14-Aug-2007, 02:40 PM #2
I can think of 2 ways to do this, one would be to use range(x,x).find and set your direction to up, with find what being "*" with a partial match

I'm not sure if it would take the asterisk as a wildcard, however...i've never tried using a .find with an asterisk, but easy enough to test.

The other option would be to to create a for/next loop, with a step -1 from the cell 1 above your data ID (i.e., if Data32 were in B20, it would start searching @ B19, stepping -1 through each row in tat column.

You could do this with a command button on the spreadsheet with an inputbox for the user to enter the data ID they're searching for, and then either select the first group member in the spreadsheet, or pop up a message box with the first group member ID.

VBA would be easiest.
StripedMeow's Avatar
Computer Specs
Junior Member with 5 posts.
 
Join Date: Aug 2007
Location: CA
Experience: Intermediate
14-Aug-2007, 03:38 PM #3
Sample:

Code:
Sub TestFind()
    Dim rngFind As Range
    Dim strWhat As String
    
    strWhat = InputBox("Enter your Find")
    
    Set rngFind = ActiveSheet.[a:a].Find(what:=Val(strWhat))
    If Not rngFind Is Nothing Then
        Set rngFind = ActiveSheet.Range(Cells(rngFind.Row - 1, rngFind.Column), Cells(1, rngFind.Column)).Find(what:="~*", lookat:=xlPart, searchdirection:=xlUp)
        If Not rngFind Is Nothing Then
            MsgBox rngFind & " " & rngFind.Address
        End If
    End If
End Sub
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:37 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.