I've a userform (UserForm1) that on closing will open one of 5 other userforms. Which of the userforms that opens will be determined at runtime, depending on an option a user has previously selected. The name of the userform is held in a cell in a workbook and is opened as follows:
I am attempting to format some TextBoxes from within a For/Next loop. I need a way to check which TextBox is the active TextBox in the loop. Using i as the variable, I came up with this code snippet: Me.Controls("TB" & i).Text = Format("TB" & i, "mm/dd/yy")
If i = 3, this gives me in TextBox3 (which is called TB3) the text 'TB3' and not the value of what is in TB3. It has got to bo something simple, I just can't see it!!!
Is there a way without using code to have the text in a text box (excel 2003), copied to another cell or another text box on a different worksheet?
I have information in a text box on 1 worksheet. I would like this information to automatically be copied to another worksheet. On the master sheet, if any of the information gets changed or updated, the copied information should get updated as well.
I need a userform textbox event that fires after I tab or click out of the textbox. Going by the list of options:Beforedragover, BeforeDroporPaste, Change, DblClick, DropButtonClick, Error, Keydown, Keypress, keyup, mousedown, mousemove, mouseup.
I can't figure out which one will do what I want. The change event happens instantaneously which doesn't work. I need to fire off the event when my focus leaves the textbox.
How do I pass values between procedures? I have two command buttons in the worksheet.
If I have a procedure A that asks user to input a value "x", when a command button is pressed. Then another command button is pressed that passes the value onto another procedure B, which iterates a msgbox as many times as the number x,
How do I pass that value x from one procedure to another?
I am building a tool that uses Pivot Tables (so I can't use track changes) and I have found cool code that will insert timestamp and username in the comment when a change occurs. But I need to modify the code to also take the old value and put it into the comment as well. Here is the code to register the change into the comment:
I think this is a relatively easy issue, but I don't know how to do it. I call the Sub SortRange in another Sub SortDeliver. A range (ran5) is defined in Sub SortRange that I also need to use in Sub SortDeliver. How do I pass the range or get the second sub to recognize the range?
I have following code which identifies two worksheets, a source (wbSRC) and a destination (wbDEST). In the following code I am trying to get the values for wbsrc and wbdest to be written to the merged spreadhseet. But I am not sure how to go about this in VBA. The commented out approach does not work.
For Each rcell In wbList.Sheets(1). Range("A1"). CurrentRegion.Columns(1).Cells Set wbDest = Workbooks.Open(rcell.Value) Set wbSrc = Workbooks.Open(rcell(1, 2).Value) wbSrc.Sheets(1).Range(copyAddress).Copy _ Destination:=wbDest.Sheets(1).Range(destAddress) 'wbDest.Sheets(1).Range("q3").Formula = "Workbooks.Open(rcell.Value)" 'wbDest.Sheets(1).Range("q4").Formula = "Workbooks.Open(rcell(1, 2).Value)"
Code: Private Sub cmdSearchButton_Click() Dim txtbox As String 'stores lookup value Dim x As Variant 'value for wwid txt box Dim ForeName As String Dim SurName As String Dim wwid As Variant Dim iPosition As Integer
Here is my code, it does a vlookup and if the persons name is not found it will split the text entered into forename and surname but when i try and add
I have a form that has three fields (1. Comments (TEXT), 2. Legacy_Comments (TEXT), 3, Comment date (DATE))
Now my users need to keep adding comments to the comment text box, and when they do it automatically adds the date they entered the comment in the Comment date box. Now my problem is that since they keep adding comments to the comment box, I need to keep track of these comments in the Legacy_Comments (Text box).
For example, the First time a user enters a comment into the (1) comment text box it auto populates the date in the comment date box, and then adds the comment and date to the Legacy_Comment box. the end result is (comment,4/3/2014 now lets say a user needs to add a comment to the comments box tomorrow - I want the legacy_Comment box to then read (comment, 4/3/2014; comment2, 4/4/2014, ...., comment(n),date(n)) OR it can be vice-verse, because I just need to keep track of the comments, I am not worried if the new comments are before or after older (yesterdays / the day before yesterdays comments)
How can I write a VBA code that will always add the new comment to the legacy_comment field, without deleting the comments that were entered previously?
Code: If isnull(me.comment.value) Then Exit Sub ElseIf me.comment.value = true Then me.comment_date.value = date me.legacy_comment.value = me.comment.value & "," & me.comment_date.value & ";" me.legacy_comment.value = me.legacy_comment.value & "," & me.comment_date.value & ";"
It adds the comment only the first time, but it does not concatenate the string from yesterday to the string to today. I do not care which order the comments are, meaning if I added a comment today it can be before OR after the comment from yesterday.
I tried looking for everywhere, but i still cant seem to find the solution.. I have an Active X textbox on a worksheet, and I need it's value to show up on a textbox on my userform, that shows up through a command button on that worksheet. I'm fairly new to vba.
I have a two-page multipage form. I have a textbox on page 1 (txtOccupantLoad), and I want to pass the value from that textbox to another textbox (txtOccLoad_L1) on page 2. The code I've tried so far looks like this:
Private Sub cmbChooseLevel_Change() If Me.cmbChooseLevel.Value = "Level 1" Then Me.txtOccLoad_L1.Value = Me.txtOccupantLoad.Value End If End Sub
What I'm trying to do is to use the same form for 10 different levels (floors) of a building. Then on page 2, I'll itemize the values for each floor. So the combobox determines which floor the calculations are for; txtOccupantLoad is the total of all incremental occupant loads on that floor; and txtOccLoad_L1 is the first of a series of textboxes on page 2 where the value for Level 1 should go. If the combo box shows "Level 2" then I'll write new code for the txtOccLoad_L2, and so on. I've also tried including "page1." and "page2." after "me."
I am trying to create a user form that has a series of text boxes that will all have a VLOOKUP function in them based off of input from a the first text box. If I can just get the code for the first one, I think I can figure out the rest. We will say that the file that the user form is contained in is 'Agent Administration' and the file that I want the VLOOKUP to pull from is called ' Roster for Auto Population'.
VB: Private Sub Workbook_Open() Call Meetdata End Sub
It calls this macro which is in a standard module:
VB: Public firstvariablename As String Public secondvariablename As String Sub Meetdata() regionname = InputBox("Enter the name of the Region.", "Region Name: North, South, East, West") meetdate = InputBox("Enter the date of the Meet.", "Date of Meet") End Sub
This set-up should make the variables available to all the other macros in the workbook. I have two other macros that need to use the values stored in these two variables that are entered into the two 'InputBox' statements. These two macros are in the same module and follow the 'Meetdata' sub. When I run the first macro, it recognizes the variables. When I run the second macro for some reason the variables are not recognized. To test the values returned by the variables, I placed the following code at the end of the first macro and again at the beginning of the second macro .
At the end of the first macro, the MsgBox returns the correct values stored in the variables which means that when the macro completes its run, the variables still hold their values. When I run the second macro with the MsgBox at the beginning, the Msgbox returns a blank. Somehow, the variables have been re-set to a null value. I can't figure out why the variables have been re-set to null. [URL]
I have created a few User Defined Types in a Main subroutine, but when I pass them into another sub the intelisense for the elements doesn't come up. I can type in the elements manually - and it all seems to work okay - but with a lot of types and elements I really want it to save me the effort.
I think I am confused as to how to declare a variable in one sub and use it as an input into another sub. I have attached some code below that assigns a value to two variables and then calls a sub that uses those values. I am brand new to programming so I guess I am confused how to implement this.
I am trying to eliminate a lot of the global variables from my program by passing the variables to my functions and subs as arguments. I am stuck though when it comes to variables created in userforms.
The program starts with a series of userforms that asks the user for information that will be used throughout the rest of the program. Data is assigned to the variables on the click events. Is it possible, without using global variables, to pass those variables to the rest of the program?
I am using the following code to open a userform. Once the userform is open, the user has the option to choose a continue button or a cancel button. If the user is choosing continue, the code is not working (it always skips to the "else" portion of my "if" statement. I can't figure out why it is doing this.
My code passes a string created by a function to procedure. It all works great, but i need to add something so that if the string = false then sub doesn't run. What's the best way to do that. Here is some of the