• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

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

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
FFengler
Asked:
FFengler
  • 4
  • 2
1 Solution
 
criCommented:
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
 
FFenglerAuthor Commented:
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
 
criCommented:
Sorry to re-ask: Do you use Forms or Control Toolbox objects ?

0
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
criCommented:
If unsure, check under View|Toolbar
0
 
FFenglerAuthor Commented:
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
 
criCommented:
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

Technology Partners: 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!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now