Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 17th, 2003, 09:33 PM
Registered User
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to KathleenS
Default Read drop-down list validated in Excel


I am working with an Excel file where one of the columns
is set up as a drop-down list validated by data from a
second worksheet. I am using VB (.NET) to read the data
in the Excel file, using code similar to:

    Dim xlApp as New Excel.Application()
    Dim xlWB as Excel.Workbook
    Dim str1, str2 as String

    xlWB = xlApp.Workbooks.Open(filename)
    str1 = xlWB.Worksheets(1).Cells(1,1).Text
    str2 = xlWB.Worksheets(1).Cells(1,2).Text

Cell 1,1 (A1) is not validated, and the program pulls the
value just fine. Cell 1,2 (B1) is validated, and after
the above command is executed str2 is set to "" even
though an item from the drop-down list has been selected
in the cell.

How do I access the value displayed in that cell?

Thanks in advance

Old August 10th, 2003, 08:41 AM
Authorized User
Join Date: Aug 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts

As an alternative you might try

    str2 = xlWB.Worksheets(1).Cells(1,2).Value

rather than

    str2 = xlWB.Worksheets(1).Cells(1,2).Text

Just a thought.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why Shipping address is not validated? webeye BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 September 18th, 2008 10:31 AM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM
Trouble putting data into Excel Drop Down List Arsi C# 2 October 26th, 2004 11:47 AM
Drop Down List mrideout BOOK: Beginning ASP.NET 1.0 8 September 16th, 2004 07:11 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.