View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Return contents of cell at Index position in Source Range of Drop

If I follow is this what you are looking for

idx = Range(bx.LinkedCell).Value
'or more simply
'idx = bx.Value
If idx Then
Val = Range(bx.ListFillRange)(, idx)
End If

One way to get help, put a break on

bx.LinkedCell = bx.TopLeftCell.Address(external:=True)


Press Alt-v s and look at bx (the ref to the dropdown) in Locals, then look
at the relevant properties in help.

regards,
Peter T

"TheMath" wrote in message
...
I have a macro that assigns the Cell link value for the Drop Down (from

Form
Tools, not ActiveX). It merely sets the Drop Down's LinkedCell to the

cell
that is under the TopLeft corner of the Drop Down control.

This causes the Index (Integer) of the selected item to be placed in the
LinkedCell. I must find the contents of the cell that is referenced by

this
number as an offset into the Input Range of cells that are specified for

this
Drop Down control. I must copy that string from the source range to

another
cell, but I don't know the VBA code to accomplish this. The part of this
code that assigns the LinkedCell works, but the line after that (the Set
SourceRange) fails with:
Run-time error '438':
Object doesn't support this property or method

Dim SourceData As Range
Dim Val as String
For Each bx In ActiveSheet.DropDowns
bx.LinkedCell = bx.TopLeftCell.Address(external:=True)
' 2 lines of psuedo-code below. What's the real syntax?
Set SourceData = Range(bx.RowSource)
Val = SourceData.Offset(bx.LinkedCell)
Next

Question 1) What is the real VBA code needed to return the contents of the
cell referenced by the Index value that is now stored in the LinkedCell?

Question 2) Where does one find the documentation for the methods and
properties of these controls from the Form Tools menu. I see all sorts of
help that deal with creating drop downs, but little about VBA reference to
their methods and properties.

--
I am the math. You know what to do.