How do I examine what can be done with an object/method/property?

foolios

New Member
Joined
Aug 4, 2011
Messages
21
I have a problem with my vba code that when I try to copy a value from a validation list, it copies the index of the selection from within that validation list.
What I want is the value that the user is trying to select and not the index.

How do I look up the abilities of the validation list? Do I used MSDN for Excel, the SDK for Excel? How does one do a search for these through those tools. I have tried using the MSDN but the links are taking me in circles.

Anyone have any advice? I want to know how to get to that value. I assumed I could use something like:
Code:
Sh_2.Cells(nxtRwVar, 8) = Sh_1.Cells(11, 18).Value
but it is also giving me the index in the same way that:
Code:
Sh_2.Cells(nxtRwVar, 8) = Sh_1.Cells(11, 18)
does.

Thanks in advance for any help.

EDIT: For example:
The validation list has Dogs at line one after it has been selected by the user.
But when I try to get that from the list with the above code I will get the index of 1. I want the actual text in that list and not it's index.
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I've tried to reproduce this behaviour but for me the Value property gives the actual selected item of the validation list, not an index.

In the VBE window, when you press F2, you get the Object Browser, there you can look up all properties and methods for all classes in the Excel class model, as well as for all referenced libraries you have active at that moment.
When you lookup 'Validation', the third search result is the Validation property of a Range. Clicking it will show you the properties and methods of that Validation property.
But I'm afraid that won't help you much here.
 
Upvote 0
Thank you for showing me how to do that.

So I will more than likely have to reference the index that is pulled from the validation list's value.
A list for the list.
I am thinking I should probably just turn the validation list into a form control(listbox).

Thank you for your help.
 
Upvote 0
It's a bit odd because I would expect that this kind of statement:
Sh_1.Cells(11, 18).Value

Would indeed return the value in the cell, not the index. Exactly as Hermanito has reported. Are you sure you are using a validation list?
 
Upvote 0
Well, now that I look at it. That's what it is doing. The cell gets the value of the selected item's index in the validation list.
I don't see a way to get to the selected value directly since a selection's index is the value placed into it's linked cell.
 
Upvote 0
To me that sounds like a combobox, not a validation list. With these kinds of things, you usually have to use a formula...but you probably also should use a range as the list source. (if you disagree and say it's really a validation list, please describe exactly how you create this validation list, and what version of excel you are using - I mean to the details of what menu items you click and so on, so we can reproduce the effect).


For comboboxes with a range as a data source, here's how you'd do it (and it may work in your situation).
Lets say there's a range for the list defined as MyRange and with three values:

Cat
Dog
Mouse

Linked Cell is defined as MyLinkedCell and currently displays:
2

Formula:
=Index(MyRange,MyLinkedCell)

Return value should be Dog

Note that with ranges as sources for lists, you can put them on other worksheets (even a hidden worksheet), but you might need to use a named range and refer to the range by name.
 
Last edited:
Upvote 0
You're right. It is not a validation list.

Your example corrected all the mistakes and misunderstandings.

Thank you so much for your help.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,473
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top