+ Reply to Thread
Results 1 to 8 of 8

Match cell value and return cell address

  1. #1
    Registered User
    Join Date
    10-25-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    17

    Match cell value and return cell address

    Hi
    Im quite new to excel programing and im stuck at a problem:

    I have 2 sheets with 1 beeing the workspace for users and the other containing data
    The function im looking for, is the when a user choose a cell in column F, a userform pops up and shows the data connected to that choice. I fixed the userform, but not how the textboxes collects the data.

    So the cell value of the cell activated, needs to be matched in column D on the other sheet and return the address, so my textboxes can use it to point to right data. I cant figure out what function i should use to do that and how it should be stored, so the textbox function can use it to collect the right data.

    Im greatfull for all the help i can get!
    Best regards Jesper

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Match cell value and return cell address

    Have a look at the VBA Find Method. This will return a range object that you can then use.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    10-25-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Match cell value and return cell address

    Hi i tryed building a find function yesterday as you suggested, but i cant seem to mamange to get it to work. Heres whats done so far :
    Attached the workwook if its better!

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Initialize()
    Dim strFind As String 'what to find
    Dim FirstAddress As String
    Dim rSearch As Range 'range to search
    Set rSearch = Kompetens.Range("d3", Range("d65536").End(xlUp))

    strFind = ActiveCell().Value 'what to look for

    With rSearch
    Set c = .Find(strFind, LookIn:=xlValues)
    If Not c Is Nothing Then 'found it
    c.Select
    With Me 'load entry to form
    .TextBox2.Value = c.Offset(0, 1).Value
    ' .TextBox3.Value = c.Offset(0, 2).Value
    '.TextBox4.Value = c.Offset(0, 3).Value
    End With

    End If

    End With


    End Sub
    Attached Files Attached Files
    Last edited by zekethewolf; 11-05-2010 at 04:47 AM.

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Match cell value and return cell address

    This example might help.

    Dom
    Attached Files Attached Files
    Last edited by Domski; 11-04-2010 at 10:04 AM.

  5. #5
    Registered User
    Join Date
    10-25-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Match cell value and return cell address

    Quote Originally Posted by Domski View Post
    This example might help.

    Dom
    Tnx, but im only getting "Subscript out of range" in that example.

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Match cell value and return cell address

    Oops, changed the sheet name after writing the code.

    I've amended the attached file above.

    Dom

  7. #7
    Registered User
    Join Date
    10-25-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Match cell value and return cell address

    Hmm can you look at the my workbook again, uppdated it with your code and changed all the variables to math my needs, but i cant get it to show the info in the textboxes.

  8. #8
    Registered User
    Join Date
    10-25-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Match cell value and return cell address

    NM that last, was just me beeing stupid. Fixed it and now it works perfectly!

    Tnx for all the help Domski!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1