I am working on a dynamically produced userform but the dynamically created Cancel and OK buttons don't work. I have been able to get round it by adding the buttons to the top of the form (non- dynamic) but I'd really like to be able to create them dynamically based on variable for other parts of the project. How can I produce dynamic command buttons that actually work?
Here's my code but I'd be happy with generic code I could use.
Private Sub UserForm_Activate() ' Define variables Dim LabelV As MSForms.Label Dim CheckboxV As MSForms.Checkbox Dim rngFields As Excel.Range Dim field As Excel.Range Dim lngNextTop As Long Dim lngTitleBarHeight As Long Dim ColumnNum As Integer
' Set constants ' Choose height and width of Label box Const cTextBoxHeight As Long = 12..............
Now i have to compile 3 years of data for 200 airports so changing the month and year for every airport would be a challenge. I can do Replace all and change the year and month but instead of that i was thinking if i could have the year and month on one row and connect the links to that cell so that whenever i drag the cell my link changes
I have a problem with a dynamic userform that I need to create.
I need a userform in which the number of controls are determined by the some values in the worksheet. The users of the workbook must be able to add new controls to the form, so I do not know the number of controls in advance. I therefore can not create the userform through the design module but must create it through code instead.
I need a userform with a number of comboboxes and a commandbutton, which when clicked sends the content of the comboboxes to the first empty row in a worksheet.
My problem is that I can't assign any commands to the comboboxes (which are created at runtime), nor can I use the values of the comboboxes in any commands assigned to other controls in the userform (e.g. the commandbutton).
I have read as far that I probably need some form of class module to create the controls at runtime, but since I am relatively new at VBA, I'm having trouble getting the class module to work in connection with the userform.
I have used this code a number of times to automatically change the scale of x axes without problem. I have just used it however and it has condensed the data so that it the line only appears in the last quarter of the chart.
Code: Option Explicit
Sub ChangeStaticAxisScales() With Sheets("Static Charts").ChartObjects("Chart 2").Chart
' Value (Y) Axis With .Axes(xlValue) .MaximumScale = Worksheets("Raw Data").Range("AN7").Value .MinimumScale = Worksheets("Raw Data").Range("AN6").Value .MajorUnit = Worksheets("Raw Data").Range("AN8").Value End With
I am using the STDEV function on a range of values: STDEV($I$26:I2545). My starting cell is constant and I would like to make my ending cell variable based on a value I enter in a master cell (A1). The value I enter in the master cell is multiplied by 252 the product would equal the row number I would like to stop at. So if I enter 1 the formula will be STDEV($I$26:I252). I tried: STDEV($I$26"I"&(A1*252))) and other such variations to no avail
I maintain Production data in an Excel Sheet and have the code which will create Chart for each Employee. Sample Sheet Attached. However, I want the Chart Range to be updated in a Single Chart and exported to a .Gif File.
Need assistance with this code provided by SHG. See attached sample. I need to create a range called DaysOff so that this function will work. As it is the function is perfect; though the accuracy if the result is dependent on the exact range, thus I need this named range to be dynamic. I have tried but it does not seem to work correctly. The named range should refer to the list of names between 1-10. The range should dynamically include any names that are listed.
Public DaysOff As Range Function datNext(datLast As Date, DaysOff As Range) As Date Dim datBeg As Date, datEnd As Date Dim iLastPd As Integer Dim iDay As Long, nDay As Long Dim iYr As Integer, iMo As Integer iYr = Year(datLast) iMo = Month(datLast) datBeg = DateSerial(iYr, iMo + 1, 1) datEnd = DateSerial(iYr, iMo + 2, 0) iLastPd = Pd(datLast) nDay = DaysOff.Rows.Count Do.......................................
Is it possible to dynamically change how values are displayed in charts?
I have a list which references different named ranges. It either needs to display the values in a graph as a number (without decimals) or a percentage depending on the source. Is this possible? Maybe with some VBA? Or am I asking too much from excel?
I've got an excel worksheet that contains charts 5-14, each with different max axes on primary and secondary scales. Right now the code below works to adjust the axes, however I have pasted this into a script 10 times, once for each chart with different references to the chart number, the max primary axis and max secondary axis. how I could write the following as a loop so that I don't need to have to repeat this routine in my code?
Sub ChartsBillingsShare() ActiveSheet.ChartObjects("Chart 5").Activate With ActiveChart .HasAxis(xlValue, xlPrimary) = True .HasAxis(xlValue, xlSecondary) = True End With ActiveChart.Axes(xlValue).Select With ActiveChart.Axes(xlValue) .MinimumScale = 0 .MaximumScale = Range("Y6").Value End With.................................
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 have the following vlookup formula in my spreadsheet.
IF(ISNA(VLOOKUP($A2,'Purchase Order Pivot Table'!$5:$500,67,FALSE)),0,VLOOKUP($A2,'Purchase Order Pivot Table'!$5:$500,67,FALSE))
It works perfectly for my current requirement, but it looks at data in a pivot table which is created from a dataset. If I name the columns in the pivot table so instead of looking at column 67 it looks at a name range will this name range change dynamically when the pivot table is refreshed? If not how can I get it to.
I have a hidden worksheet (in my add-in) where I store various configuration options for my processing. Among these are some cell formats that I apply to a target worksheet for the user to reformat their sheet.
I want to give the user the option to change some of these formats (font name, size, color, interior color). Is there a way to use a userform textbox to let the user format the text and fill options, or how would you recommend I do this?
I want to be able to store these options in my hidden config sheet so they can be applied every time, but do not want to unprotect the user worksheet for them to make the changes there.
Below is code i wrote to change a password. password value is hidden in cell iv4 in different sheets. My userform contains 3 textboxes and button to run macro. As long as old password matches cell value AND new password is entered twice correctly then it will change value in cell iv4.
I've got a userform for entering data in a workbook with sheets for each month. ie: Jan'06 , Feb'06, etc. I've added a combobox that looks at my list of these sheets and when a certain month is chosen I would like that months sheet to come up behind the userform, so that the data is entered there when the form is completed.
The other option is to not change the sheet focus but to direct the data to the appropriate sheet based on the combo box. (No matter what sheet is currently selected)
On a related note, I have a text box showing the last date entered and I would like to make shure that it is updated based on the sheet selected in the combobox.
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.
I have a Password login userform on my workbook for users to enter their username and passwords.
Now i want to make a userform where users can change their passwords.
With the login userform i used a application vlookup function to see if the username and password are corresponding. how can i code a userform to look for the username in column A and then change the password in column B?
Is there a way to call a subroutine anytime any control is changed within a userform?
I have a userform that needs to go through and add/multiply almost every value in every textbox and also add together values associated with checkboxs. I need this to happen anytime a textbox value is changed or a checkbox is checked.
I have a userform with Option Buttons. I have them all initialized as deactivated except for one at a time as the user performs certain tasks (e.g. Create a new worksheet with the name "database"). Once each task is completed, the previously activated option button becomes deactivated and another option button becomes activated. That works fine. My problem now is that I can't change the default tab index settings to put the black dot next to the activated option button:
This doesn't seem to work:
Code: If Sheets("Database").Range("A1") vbNull Then Controls("OptionButton1").Enabled = False Controls("OptionButton1").TabIndex = 1 Controls("OptionButton2").Enabled = True Controls("OptionButton2").TabIndex = 0 End If
I would like to set the value of a toggle button when the userform is opened so that it coincides with the what columns are hidden on screen. Below is simple example which I have not tested or debugged. It was just what i was thinking.
Sub Macro2() 'if col A is hidden If Columns("A").EntireColumn.Hidden = True Then 'make hidecalcs toggle button true (sunken) Userform1.HideCalcs.Value = True