LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Referring to control value on form using variable name for control

Using Excel 2007, but have same problem in 2003. And to be clear, this is
about actual user fomrs, not controls on a worksheet. I see a lot of stuff
on Google and in the groups about dealing with controls when they're
inserted into worksheets, but this is about those user forms you design in
the VBA editor.

I am trying to add a completely new aspect of pricing to a kind of
hurky-jerky-typical-started-out-small-then-kept-getting-added to excel
application hat I've been dropped in the middle of:

Looping through the list of controlnames listed in a worksheet (this is
going on behind the scenes while the form's showing and being interacted
with), If the left 6 characters of the control's name are "BrkQua", then it
is a textbox, and I need to take the value that is in that textbox (the one
on the form) and do a Vlookup function that performs price breaks based on
quantity (I got the Vlookup part from the ozgrid site, I believe).

So, for every control whose name starts with "BrkQua", I look up that
control's value in a specific range in a spreadsheet, and multiply that
value by what my Vlookup gets.

My problem so far is referring to the value of these controls. It seems
that when I have a control's name in a variable, I can't refer to it's
value. If my variable is ControlName, then this works:

If Left(ControlName,6) = "BrkQua" then
MsgBox ControlName, vbOKOnly,""
End If

This will give me a popup with the actual whole name of the control.
However, when I try
If Left(ControlName,6) = "BrkQua" then
MsgBox ControlName.value, vbOKOnly, ""

Gives me a syntax error, or I get other errors when I try
Controls(ControlName).value or other variations I've tried using parenthesis
and quotes and things. I can't seem to find a way to have a control's name
be in a variable, and while in my loop access the value of that control.

Can someone help me with this?

Your assistance would be greatly appreciated, and thanks for reading.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
Using a Form to control variable fields. Memphus01 Excel Programming 8 March 18th 09 05:33 AM
variable form control Roman[_4_] Excel Programming 2 June 15th 05 08:20 AM
Variable Reference to a Form Control Sharlene England Excel Programming 2 November 5th 04 10:56 PM
Tool Tip Text for Form control/ Active-X control Freddie[_2_] Excel Programming 0 October 19th 04 04:14 AM


All times are GMT +1. The time now is 09:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"