Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading values by VBA of ComboBoxes/Textfields which are included directly in a table sheet

Posted on 2001-06-26
6
Medium Priority
?
252 Views
Last Modified: 2012-06-21
Hi Experts,

how can I read the values of ComboBoxes,Textfields and other Objects, when they are included directly in an Excel sheet ?

It should start with ThisWorkbook.Sheets(1). ???

Thanks for the help

FFengler
0
Comment
Question by:FFengler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 13

Accepted Solution

by:
cri earned 150 total points
ID: 6228438
Do you use Forms or Control Toolbox objects ?

For _Forms_ calacuccia answered this for me once in
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=msoffice&qid=10352410:

xxxxxxxxxxxxx

Ctrl defines the name of the form to be analysed, description = 1 will tell  if the choosen item in the ListBox or ComboBox has to be displayed instead of the value. The value of Description is negliged for CheckBox and OptionButton forms.

Function MyRet(Ctrl As String, Description As Boolean)
Dim mctr As Shape

Application.Volatile 'Only if used from worksheet side
Set mctr = ActiveSheet.Shapes(Ctrl)

If mctr.Type <> msoFormControl Then Exit Function

Select Case mctr.FormControlType
   
   Case xlListBox
   If Description = 0 Then
       MyRet = mctr.ControlFormat.Value
   Else
       MyRet = ActiveSheet.Range(mctr.ControlFormat.ListFillRange).Cells(mctr.ControlFormat.Value)
   End If

   Case xlDropDown
   If Description = 0 Then
       MyRet = mctr.ControlFormat.Value
   Else
       MyRet = ActiveSheet.Range(mctr.ControlFormat.ListFillRange).Cells(mctr.ControlFormat.Value)
   End If

   Case xlCheckBox
   If mctr.ControlFormat.Value = -4146 Then
       MyRet = True
   Else
       MyRet = False
   End If

   Case xlOptionButton
   If mctr.ControlFormat.Value = -4146 Then
       MyRet = True
   Else
       MyRet = False
   End If

End Select

End Function
0
 

Author Comment

by:FFengler
ID: 6231252
Hello cri,

I included your Function into my Code. When I tried to read the value of a Checkbox which is directly included in a Sheet, I get an error within your function because the Checkbox  cannot be found.

The call of the function is as follows:

 s.verz = MyRet("VerzeichnisBox", False)

"VerzeichnisBox" is the name of the Checkbox
I changed the function to refer to a special Sheet in the workbook:

Instead of
Set mctr = ActiveSheet.Shapes(Ctrl)

I use
   
Set mctr = ThisWorkbook.Sheets("Allgemein").Shapes(Ctrl)

which should also work.


where's the mistake here ?

Thanks
0
 
LVL 13

Expert Comment

by:cri
ID: 6232377
Sorry to re-ask: Do you use Forms or Control Toolbox objects ?

0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 13

Expert Comment

by:cri
ID: 6232381
If unsure, check under View|Toolbar
0
 

Author Comment

by:FFengler
ID: 6242091
Hi cri,

I am using Control Toolbox objects (out of the control Toolbox) which I put directy into a table sheet, I am not using a form for this.

0
 
LVL 13

Expert Comment

by:cri
ID: 6243025
As stated in my post of 06/26/2001 the code reads the values for Form _objects_. These are the predecessors of the ActiveX bloats. I use nothing else.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question