473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Selecting a control based on cell information

4
Hello,

I have 40 option boxes in a list, beside information in cells (in excel). I want to be able to select a control (ie Control27) based on information in the cell beside it (would be cell N27 for instance), but I haven't found a way to do that. Can anyone help please?
Oct 18 '06 #1
4 1217
albertw
267 100+
Hello,

I have 40 option boxes in a list, beside information in cells (in excel). I want to be able to select a control (ie Control27) based on information in the cell beside it (would be cell N27 for instance), but I haven't found a way to do that. Can anyone help please?
hi
can you rephrase your question as it not clear what you want to accomplish.
as i read it:
you want to select an optionbox based on information in a cell beside it?
what information ? a number ?
get the cell's contents, use this as an index
(hope you have your optionboxes in an array, otherwise you may forget the story)
then,
OptionBox(Number).Value=1
Oct 25 '06 #2
Jono
4
I think what I really need to be doing is getting my checkboxes in an array. How do I do this? I have 40 and I want to be able to iterate through the whole set, but currently I have to refer to each individually... Any ideas?

Ie my code so far would be as follows...

With ActiveSheet
.Option1.Value = False
.Option2.Value = False
.Option3.Value = False
(and on and on until 40...)
End With

Please help!
Oct 27 '06 #3
albertw
267 100+
I think what I really need to be doing is getting my checkboxes in an array. How do I do this? I have 40 and I want to be able to iterate through the whole set, but currently I have to refer to each individually... Any ideas?

Ie my code so far would be as follows...

With ActiveSheet
.Option1.Value = False
.Option2.Value = False
.Option3.Value = False
(and on and on until 40...)
End With

Please help!
hi

sry, took some time to figure things out.
mistaken vba for vb6 where you can use Index as arraycounter
maybe next thing is some use to you
no need to rename all your optionbutton names - taken into account that ALL of them start with "OptionButton" followed by a number.


Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub SetOptionButton()
  3. Arg = Range("a1").Value
  4. ButtonName = "OptionButton" & Trim(Str(Arg))
  5. ActiveSheet.OLEObjects(ButtonName).Object.Value = True
  6. End Sub
  7.  
  8. Private Sub ResetOptionButton()
  9. For Arg = 1 To 40
  10. ButtonName = "OptionButton" & Trim(Str(Arg))
  11. ActiveSheet.OLEObjects(ButtonName).Object.Value = False
  12. Next Arg
  13. End Sub
  14.  
  15.  
Oct 30 '06 #4
Jono
4
Thank you!! Your idea led to me eliminating 220 lines of code!! Geez that sure is cleaner now. Anyways, in case anyone else can benefit from this in the future, here is what I ended up with. Far from perfect, but hey, I'm just starting..

Dim Loc As String
Loc = ActiveSheet.Range("Q7").Value
Dim Incr As Integer
Incr = 1

Do While Incr < 41
If Worksheets("Attachments").Range("B" & Loc).Value = "D" Then
OptionName = "Option" & Trim(str(Incr))
ActiveSheet.OLEObjects(OptionName).Object.Value = True
End If
Incr = Incr + 1
Loc = Loc + 1
Loop
Oct 31 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Axial | last post by:
Question: How to select columns from Excel-generated XML when some cells are empty. I've found examples where rows are to be selected, but I can't seem to extrapolate from that to selecting...
1
by: ET | last post by:
Please help with the query: There are two tables, A and B. A table has information about cell phones, like cell number, sim number, model, manufacturer etc... B table has user related...
1
by: orekinbck | last post by:
Hi There I have a datagrid whose main purpose in life is to provide a nice way for users to make a single choice from a list. The grid is read only, single row select and has its data source as...
0
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading...
0
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to...
3
by: Shevek | last post by:
Hi All, Hope someone can help! I am building an Event Calendar app based around the Calendar WebControl which builds an SQL string based on the SelectedDates property which is passed to...
1
by: Jonathan | last post by:
Hi, i am new to Asp.Net and i am not sure wich option i should go for. What i wanna do is simply to change some information in a cell. As a matter of fact, each hyperlink on my Web page will...
10
by: Alan Lambert | last post by:
I am writing a web-based reporting tool and using a datagrid to display information returned from a database. I am displaying column headings from bound columns with no problems but I need to...
0
by: Umut Tezduyar | last post by:
I have a control derived from ComposeteDataBoundControl. Control doesn't retreive it's state information. I am going to frick out! What should I do more? I added two codes. One is for Default.aspx...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.