+ Reply to Thread
Results 1 to 6 of 6

userforms calling cells from a different sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    6

    userforms calling cells from a different sheet

    Hello, I am looking for some guidance. This is my first time using macros and userforms in excel 2007. My problem is that I am trying be able to select a cell in sheet1 and it brings up a userform with labels that call up the information that I need that's in sheet2. Along with this I also need when I select another cell it brings up the information that is specific to that cell. An example would be if I have cell A1 as John S. I select it and it brings up all the information I need for him and in A2 I have Mary B., if I select this cell it brings up her information, etc., etc.

    I am not really sure where to start. Thanks in advance.
    Last edited by seansimi; 05-01-2013 at 09:45 PM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: userforms calling cells from a different sheet

    attach a sample file with all informations
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: userforms calling cells from a different sheet

    Example.xlsmHere is a quick example. I want to select cell A2, and when I do I want it to bring up the userform. This userform will then find then information from sheet 3 that corresponds to the cell by name. When I select cell A3 I need it to do the same thing.

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: userforms calling cells from a different sheet

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      If Target.Column = 1 Then
        name1 = Target.Value
        Call nfind(name1)
      End If
    End Sub
    
    Sub nfind(name1)
    Dim c As Range
    With Sheets(3).Range("A:A")
      Set c = .Find(name1, LookIn:=xlValues)
      UserForm1.lblAddCap.Caption = c.Offset(0, 1)
      UserForm1.lblAdd2Cap.Caption = c.Offset(0, 2)
      UserForm1.lblStateCap.Caption = c.Offset(0, 3)
      UserForm1.lblZipCap.Caption = c.Offset(0, 4)
      UserForm1.Show
    End With
    End Sub
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: userforms calling cells from a different sheet

    Thank you patel45 and sorry I didn't post sooner. For the example I gave it worked perfectly. I transferred over to what I am working on changing all of the label names and all but once I select the next cell it gives me a Run-time error '91': Object variable or With block variable not set. The only thing that I have different from the example that I posted and what I am working on is that I have merged cells. Any ideas of why I am getting this error code?

  6. #6
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: userforms calling cells from a different sheet

    Okay it is working now. For some reason there was an issue with the way I have in one sheet to what it was searching for. I just did a copy/paste and it started to work. Thank you again patel45.

+ 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