VBA - Change Caption Of ActiveX Checkboxes Using A Loop
Jan 24, 2013
I am trying to change checkboxes caption name using a loop so that I don't have to change them individually. Here is a simplified example of what want to do:
1) I save the caption names in a array
2) I run through a loop to rename each checkboxes using the names saved in the array
Sub change_Checkbox_Caption
Dim MyArray(1to3) as string
Dim IndexMyArray as integer
MyArray(1) = "YES"
MyArray(2) = "No"
MyArray(3) = "Maybe"
I needed to put a Checkbox on a Worksheet. The standard Checkbox options in Excel FormControl and ActiveX Control were too small. I found a work-around using the following macro attached to an ActiveX Label that was formatted as Wingdings font. The macro basically changes the character from a empty box Wingdings Chr(168) to a checked box Wingdings Chr(254) when the user clicks on the label.
Private Sub Label1_Click() If Label1.Caption = Chr(254) Then Label1.Caption = Chr(168)
[Code]....
But I get this error on an ErrorHandler that I have included in the macro. "An error has occurred. Error number =438. Error Description=Object doesn't support this property or method."
As soon as i mark checkbox1, i want to send the checkbox Caption to A1. Then if i choose checkbox5 and mark it, i want to send the checkbox Caption to A2, which is in this case next cell available on colA.
I have one Sheet for each day of the month, named 1,2,3,4 and so on. Each Sheet is copied from the second Sheet upon creation, so they are all the same, except for the first sheet. On each Sheet there are a couple of checkboxes (four at the moment) placed at the same position och each Sheet.
If, let's say the first checkbox on Sheet 6 is checked, then the next seven Sheets checkboxes that is placed on the same spot should become triple-state. I want this to happen in real-time, not when the Sheets are copied/created. In other words, when I click a checkbox on any given day (Sheet), the next seven checkboxes on the upcoming 7 Sheets should change state.
This is to say "this is ok for seven days, and if there has gone 7 days since the last click - the checkbox is empty.
I'm looking for a way to loop through the ActiveX controls (option buttons) in one sheet so that I can have these option buttons reflect what I select on the front sheet.
Is it possible to distinguish a checkbox that is inside a frame from one that is outside it? What I am trying to do is loop through all the checkboxes on a multipage but only those that are within a specified frame.
I have a userform with several checkboxes which relate to different areas to run a report on. In total i probably have 70 odd checkboxes which are set out in groups according to what they relate to (on a multipage on the userform)
I've set out the option to 'select all checkboxes' within a particular group which may contain a certain number of checkboxes (but not all). I'd like my model to run reports to the selected group of checkboxes rather than all of them.
So for example, on page 2 of my multipage i have 5 checkboxes which i've named in the GroupName section in properties as Group1. When my user selects the relevant 'Run Group 1 Reports' button on Page 1 i'd like my model to ru though code using the group of 5 checkboxes relating to Group1.
some of my groups will be for 30 / 40 checkboxes and running it though groups would save a lot of time.
it's been a while for me so bare with me. I've created a user form with four checkboxes each representing a worksheet. I want to loop through all the checkboxes and those that are checked should be printed.
I have just noticed that there is no defult event for the running code after updating a label caption. I would like to have like a textbox does (Change,AfterUpdate). to run code on the label caption change. could it be done with activex?? can it be done at all.??
Background: I currently have an some VBA code that will kick off a series of calculations on a remote server (7 calcs). I am showing a modeless form, to allow the user to continue to work in Excel while the external calculation is taking place. The code checks every few seconds (using .OnTime) to check the status of the calcs, and as one finishes, it starts the next calc, and updates the form (ie - "Running Calc #3 of 7", etc).
Problem: when I change the label on the form, it gives the form focus. So, if the user is in the middle of doing something, they are suddenly stopped, and have to click back on the spreadsheet to continue.
Questions: Is there a way to update content (label) on a form, without that form getting focus? If not, is there another way to provide updated feedback without disrupting what the user is doing? My fallback is to simply not update the form with progress reports, but since the calcs can take 5min or so, it would be good if they knew things were progressing.
How do you references the properties of a shape? I am having trouble with 2 different types. Firstly, I have a worksheet with a group of commandbuttons (all added using the Control toolbox) and I want to loop through them changing, for example, the enabled property of each to TRUE.
Secondly, I have some commandbuttons on a worksheet (added using the Forms toolbox). How would I loop through changing, say, the text on the buttons. I used the macro recorder to try to get an idea and got the following:
Sheet1.Shapes("button 15").Select Selection.Characters.Text = "New Text"
Although this works, it is not very elegant, how can it be achieved without selecting the button each time, but rather by directly accessing the property.
I present a form (a calendar) twice in my routine to the user but I want to change the Caption of the Label on each pass?
e.g.
The first time it's displayed: 'Please select a start date' (calendar closes & goes off and does stuff) ... and on the 2nd display: 'Please select an end date'.
I am trying to edit a textbox caption in an active chart with a macro and cannot figure out the correct way to reference the text property. I have been successful in editing other items within this chart via the complete code below (i currently have textbox edit commented out)
[Code].....
I know i can set it up with a helper cell to have the textbox reference a range (that updates with the text i want) but i'd to try and edit the text without the use of helper cells to try and make this a little more break resistant.
For a form that dynamically creates a series of text boxes and labels, does anyone know how to change the caption of a dynamically created label to display the value of a cell in a worksheet? The cell in the worksheet changes according to input on the text boxes. In the form's code, I have:
Dim newLblFreq As MSForms.Label Set newLblFreq = Me.Controls.Add("Forms.Label.1", "lblfreq" & i, True) newLblFreq.Caption = Range("V" & i).Text & " Hz"
But once the label is created, the caption won't change, even if Range("V" & i) changes...............
I'm a complete Excel and VBA newbie and would like to know if it's possible to change the output of OptionButtons from 'TRUE' or 'FALSE' to "1"/"2"/"3"/etc..
The name of each button is:
Rating 1 Rating 2 Rating 3 Rating 4 and so forth..
The idea is for each rating to output its assigned number such that if the user were to click "Rating 1", the result would be "1", "Rating 2" = 2 and so on. I'm trying to design a survey and these results will then be used to calculate an average rating. If this is possible, how would I need to write the code for it?
I'm amtepting to populate some labels from some predefined strings based on the scrollbar value. I have these codes:
Option Explicit Public Meddelande1 As String, Meddelande2 As String, Meddelande3 As String, Meddelande4 As String, Meddelande5 As String, Meddelande6 As String, Meddelande7 As String, Meddelande8 As String, Meddelande9 As String
Private Sub UserForm_Initialize() On Error Resume Next Workbooks("Kontrollsystemet.xls").Close SaveChanges:=False Application. ScreenUpdating = False Workbooks.Open "V:allaBeredningKontrollsystemetKontrollsystemet.xls", ReadOnly:=True Sheets("Meddelanden").Activate Meddelande1 = Range("B2").Text Meddelande2 = Range("B3").Text....................
As an aid, I have a label at the bottom of the form and when a person tabs onto a textbox that labels then states what you are supposed to input into that textbox along with an example. When you tab onto another textbox the caption on the label changes to give another explanation and example.
I attempted to insert an if statement into the userform which states that if a textbox is enabled then the caption of the label = "Example"
If textbox1.enabled = True Then label1.caption = "Explanation 1, Example 1" If textbox2.enabled = True Then label1.caption = "Explanation 2, Example 2" End If End If
How can I change the name of toggle button to "Disbale Download" after clicking on the toggle button? I am trying to find the answer on WROX Excel 200 VBA but I am lost.
After scouring the entire OzGrid, I have found the following two macros that partly satisfy what I want to achieve. BTW, following two macros are executed on Sheet2 and I want to achieve the following: On Worksheet_Activate, show columns that match the criteria value in Sheet1.D4 (Sheet1.D4 contains a dropdown list with about 6 text values). In addition to that, if Sheet1.D4 value is blank then show all columns. Right now, it successfully shows columns that match the D4 value but does not work if that D4 value is left blank, instead it hides all columns in range (C:CV). So in short, to the first macro, I need to add the criteria if D4 is blank, then keep the sheet intact and don’t hide anything, just show all columns.Once on that sheet after the Worksheet_Activate event has occurred, with the second macro “ToggleColumnsVisibility” following things need to happen. BTW, currently this macro is assigned to a button (from Forms Toolbar).If cell D4 has a value, then the button’s caption should read “Show All” and when that button is pressed, it should show all columns in the range (C:CV), and the button's caption needs to change to “Show Selected”. In “Show Selected” mode, when that button is pressed, it needs to show all the columns that match the D4 value.If cell D4 is left blank, then the button's caption should read "No Action" and when the button is pressed, it should not do anything but just show all columns.
As you will notice in the header, my experience with Excel is very limited, so detailed instructions will be greatly appreciated. I am also hoping that proposed solution uses some of the efficient/effective ways of using loops such as described below (example taken from this website from this link http://www.ozgrid.com/VBA/SpeedingUpVBACode.htm)
Sub TrueOrFalseFaster() Dim bYesNo As Boolean Dim i As Integer bYesNo = (i = 5) MsgBox bYesNo End Sub
Sub ToggleTrueOrFalseFaster() Dim bYesNo As Boolean bYesNo = Not bYesNo MsgBox bYesNo End Sub .........
I have a sheet with many active x check boxes already created but with visibility off. I want code that turns on the visibility, repositions, and checks certain check boxes whose name is based on values in an array named configs.
Here is the code with the problem line indicated:
[Code] ........
The repositioning and visibility work fine. I get an "object doesn't support property or method" error on the indicated line. What is the proper syntax to do this?
I have one sheet with about 100 activex controls (and another few 100 on the other sheets in the file), most combobox, but some checkbox as well. There are 30 of them lined up, one in each row. One at a time, one control will basically change to an icon only. If you select it in design mode, the name shows in the range name area of the toolbar, but when you select properties you get the properties for the sheet. Effectively I have an icon with nothing linked to it anymore.
For a while, it seemed to be somewhat random. But for the last few days, it is now cascading down. First combobox #6, then #7, etc. I'm now on #11 or so. Seems to happen when you save then reopen the file, not if you just keep working in the file without closing it.
The macros behind the boxes are still there and run once I recreate the missing box (normally with an Alt-D, and editing the properties; but I've also created from scratch from the toolbar, and used alt-C, alt-V) they work fine. I've run a compile, with no change. Any thoughts on finding the root cause? I thought it might be from blowing up a macro, but I've tried it without even editing a macro and it has the issue.
It has been awhile since I've worked on anything and I can't remember how to do something that is probably very simple. I have placed an option button on my worksheet and cannot for the life of me remember how to change the properties. When I right click and select properties a box pops up but there is no info there. I want to be able to change the name and group etc.
I want to be able to change 2 cell info based on 4 checkboxes used. So based on a check box i check, it will populate what info i assigned to it the box. See below,
1 cell12342 cell
I have 4 checkboxes and 2 cells i need populated by whatver box i check. I have the following formula, but not sure how to tie in all the cells together.
=IF(A1,"Checked message",") If 1 CELL gets changed when checked, i need 2 CELL to change as well. Example, I checked box one and so 1CELL should change to, lets say to a set dollar amount like $12, and then 2CELL would also change to another entry say a set dollar amount, like $15 or whatever both based on checkbox one. BUT i also want to populate those same 2 cells with different amounts if i check the other boxes.