+ Reply to Thread
Results 1 to 6 of 6

Adapt macro to select from list - Excel 2010

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    8

    Adapt macro to select from list - Excel 2010

    I am trying to adapt these two macros listed here:

    http://www.excelforum.com/excel-gene...r-of-word.html

    to my workbook. The cell that needs to populate is A7 in sheet 1 and my data list is in sheet 2 cells A1-A325 (it's also a named range: EmpList). I get a runtime error 9 when I run it.

    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Adapt macro to select from list - Excel 2010

    Can you upload the workbook that you are trying to adapt and the code you used?

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Adapt macro to select from list - Excel 2010

    Quote Originally Posted by MrsRobinson View Post
    I am trying to adapt these two macros listed here:

    http://www.excelforum.com/excel-gene...r-of-word.html

    to my workbook. The cell that needs to populate is A7 in sheet 1 and my data list is in sheet 2 cells A1-A325 (it's also a named range: EmpList). I get a runtime error 9 when I run it.

    Thanks!
    Consider using an ActiveX Combobox control from the Control Toolbox toolbar. You can position it to fill cell A7 and set these three properties (right-click and select Properties)
    LinkedCell: A7
    ListFillRange: EmpList
    MatchEntry: 1 - frmMatchEntryComplete

    The user can type in an entry and it will match it from the list as they type, or they can select an entry from the drop down list.

  4. #4
    Registered User
    Join Date
    09-20-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Adapt macro to select from list - Excel 2010

    I can't upload the workbook - confidential employee info. However, here are the macros:

    This one in a module:

    Sub ShiftList(sLetter As String)
    Dim MyRng As Range
    Dim SearchFor As String
    Set MyRng = Worksheets("Sheet2").Range("A1:A300")
    SearchFor = sLetter & "*"
    On Error Resume Next
    MyRng.Find(What:=SearchFor, After:=MyRng(MyRng.Count), _
    LookAt:=xlWhole).Activate
    If Err <> 0 Then
    MsgBox "The letter '" & sLetter & "' cannot be found."
    Err.Clear
    Exit Sub
    End If
    On Error GoTo 0
    With ActiveWindow
    .ScrollRow = ActiveCell.Row
    .ScrollColumn = 1
    End With
    End Sub

    this one in sheet 1:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target = "" Then Exit Sub
    If Target.Address(0, 0) = "A7" Then Call ShiftList(Range("A7").Value)
    End Sub

    I will try the combobox, meanwhile...thanks!

  5. #5
    Registered User
    Join Date
    09-20-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Adapt macro to select from list - Excel 2010

    AlphaFrog, I've tried every way I can think of to enter my range (i.e. with quotes, without quotes, named range, actual range, etc.) but ListFillRange goes blank after every entry...

  6. #6
    Registered User
    Join Date
    09-20-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Adapt macro to select from list - Excel 2010

    Okay, figured it out - I'm going with the combobox. Thanks for the input!

+ 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