Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3347622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:26:37+00:00 2026-05-18T01:26:37+00:00

I have the following VBA code (from MS Access 2007). The code creates a

  • 0

I have the following VBA code (from MS Access 2007). The code creates a new workbook and adds a dropdown to a cell. This small snippet adds a drop down to a particular cell and the adds some items to it.

Dim myRng As Range
Dim myDD As Dropdown
Set myRng = wSheet.Cells(row, col)
With myRng
    Set myDD = .Parent.DropDowns.Add(Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)
    myDD.AddItem "msg1"
    myDD.AddItem "msg2"
    myDD.LinkedCell = .Parent.Cells(row, col + 2).Address(external:=True)
End With

This all works great and when I open the spreadsheet I get a combo box where I want and the items are displayed. However when I select an item the from the drop down in Excel the linked cell shows 1 or 2 (the index number). I would like it to show either msg1 or msg2.

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:26:38+00:00Added an answer on May 18, 2026 at 1:26 am

    A few options.

    You could put a data validation drop down in the cell rather than a Dropdown object. This returns the actual results rather than the index. If you still need a separate linked cell, you can put a formula that simply copies the dv cell

    Sub MakeDv()
    
        Dim wSheet As Worksheet
        Dim myRng As Range
    
        Set wSheet = ActiveSheet
    
        Set myRng = wSheet.Cells(row, col)
        myRng.Validation.Add xlValidateList, , , "msg1,msg2"
        wSheet.Cells(row, col + 2).Formula = "=" & myRng.Address
    
    End Sub
    

    Another option is not to use the LinkedCell property and use a macro to write the value. Assign this macro the Dropdown

    Sub ShowDDResult()
    
        Dim dd As DropDown
    
        Set dd = ActiveSheet.DropDowns(Application.Caller)
    
        ActiveSheet.Cells(row, col + 2).Value = dd.List(dd.Value)
    
    End Sub
    

    That may not be so easy if you’re creating the worksheet from scratch from Access because you’d have to add the macro. The final option is to use the ListFillRange property to fill the Dropdown. Put the list in a range and use a formula off of the LinkedCell to pull the date out of the list

    Sub testdd()
    
        Dim wSheet As Worksheet
        Dim myRng As Range
        Dim myDD As DropDown
        Dim rList As Range
        Dim aList(1 To 2, 1 To 1) As String
    
        Set wSheet = ActiveSheet
        Set rList = wSheet.Range("D1:D2")
    
        Set myRng = wSheet.Cells(row, col)
        aList(1, 1) = "msg1": aList(2, 1) = "msg2"
        rList.Value = aList
    
        With myRng
            Set myDD = .Parent.DropDowns.Add(Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)
            myDD.ListFillRange = rList.Address
            myDD.LinkedCell = wSheet.Cells(row, col + 2).Address
            wSheet.Cells(row, col + 3).Formula = "=INDEX(" & rList.Address & "," & myDD.LinkedCell & ",1)"
        End With
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in VBA (which resides in an Excel 2007 Workbook):
Hey fellas, I have the following VBA code. It gets the values from an
In Excel 2007 I have the following very simple code in VBA: Public Type
I have been trying to make a VBA code to do the following. I
I have the following code that executes a Stored Procedure in Sybase throught VBA.
I have the following VBA code inside an Excel macro: With ActiveSheet.QueryTables.Add( _ Connection:=ConnStr,
I have the following vba code to find occurrences of 0 in a following
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
Suppose I have following string: String asd = this is test ass this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.