Consulting

Results 1 to 8 of 8

Thread: Converting normal cell into DropDown List

  1. #1

    Converting normal cell into DropDown List

    Hi, I am trying to conver a normal excel cell into a dropdown list with defined values at runtime. Request help.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just go to Data>Validation, choose a type of list, and enter the range reference in the box.

  3. #3

    Need help to do this from VBA

    Quote Originally Posted by xld
    Just go to Data>Validation, choose a type of list, and enter the range reference in the box.
    Thanks for your post. Actually, I am trying to do this at runtime from a VBA code. Sorry that I did not explicitly mention about it in my first post. Any help is appreciated.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just do it from in Excel with the macro recorder switched on, you will get all the code that you need.
    Last edited by Bob Phillips; 01-16-2007 at 05:45 AM.

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    [VBA]Option Explicit
    Sub NumberRowsAndCreateList()
    Application.ScreenUpdating = False
    [A:A].ClearContents
    With [A1:A10000]
    .Formula = "=ROW(B1)"
    .Value = .Value
    End With
    With [D110].Validation
    .Delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
    Operator:=xlBetween, Formula1:="=$A:$A"
    .IgnoreBlank = True
    .InCellDropdown = True
    .ErrorTitle = "ERROR"
    .InputMessage = "Select from list"
    .ErrorMessage = "Please select from dropdown list only"
    .ShowInput = True
    .ShowError = True
    End With
    ActiveWorkbook.Save
    [D1].Select
    Application.ScreenUpdating = True
    End Sub
    [/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I'll bet the macro recorder never came up with this abomination

    [vba]

    [A:A].ClearContents
    [/vba]

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Your right Bob....no need for that but it couldn't be much worse with the recorder.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8

    Thanks

    Quote Originally Posted by xld
    Just do it from in Excel with the macro recorder switched on, you will get all the code that you need.
    Thanks a looooot! Why did it not click to me? Thanks again.

Posting Permissions

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