userform

How to save the values in a userform in vba?

自作多情 提交于 2019-12-24 01:54:31
问题 I have a userform which looks like this All the textboxes are filled with default values once a user opens this form. The user then changes the values manually and presses OK which will close the form and will affect the charts linked to the form. If the user opens the form again, the values in the textboxes revert back to default ones and the charts linked will assume their default positions too. Is there any way where once the user presses OK, the values in the userform gets saved so when

Setting combobox values on initialisation and change of other comboboxes

痴心易碎 提交于 2019-12-24 00:53:53
问题 (EDIT: To clarify, I'm running Excel 2013, so Microsoft's date picker isn't available.) I'm trying to code a simple date picker - it'll be tidier when it's done, it's just big for simplicity while I build it - and everything populates as it should: Me.Combo_Year.List = wsLU.Range("Date_Years").Value Me.Combo_Month.List = wsLU.Range("Date_Months").Value Me.Combo_Day.List = wsLU.Range("Date_Days31").Value However, there are two instances where I'd like to set default values for the year, month

Userform - Return to public sub from private sub

北城余情 提交于 2019-12-24 00:44:10
问题 I have the below code which is a private sub which is initialized from Userform3.show in a public sub, as far as I am aware the code below works however it does not return to the public sub on completion. Please note when I change the value of sheet8.range(I16) another private sub is called. However I believe the below code is the issue. Can anyone advise how I can get the private sub to return to the public sub on completion? Private Sub UserForm_Initialize() 'populate "Combo-Box with Boards

VBA dots from database get loaded into textbox as comma

我只是一个虾纸丫 提交于 2019-12-23 22:52:51
问题 I know the Headline sounds odd so I will start off with a screenshot: As you can see, the problem is that the point suddenly changes to a comma when I look up an ID in the UserForm. Before recalling Infos, I am saving all Information rather straightforward: with ws Range("BH" & lastRow).value = Me.payinfoOnTime Range("BI" & lastRow).value = Me.payinfo30 Range("BJ" & lastRow).value = Me.payinfo60 Range("BK" & lastRow).value = Me.payinfo90 Range("BL" & lastRow).value = Me.payinfo90more End with

VBA Userforms used with no explicit instantiation

我的梦境 提交于 2019-12-23 15:49:49
问题 Let's say I have a userform called MyUserForm that I use like Dim form as MyUserForm Set form = New MyUserForm form.SomeVar = "Hi" form.Show ' Displays "Hi" somewhere on the form and all is fine and dandy. But the following, and this is what strikes me as odd, works as well: MyUserForm.SomeVar = "Hi" MyUserForm.Show which looks like there's some implicitly declared object MyUserForm whose type is precisely the class MyUserForm ! What is VBA really doing here? What are the rules governing this

Adding event listener to several comboboxes

旧城冷巷雨未停 提交于 2019-12-23 12:24:32
问题 I'm basically trying to display different sets of textboxes on a userform depending on the value taken by a combobox. I have created a class module called CControlEvents in which I describe the events that should occur when I change the value of the combobox : Private WithEvents mclsCbx As MSForms.ComboBox Private WithEvents UnitmclsTbx As MSForms.TextBox Private WithEvents UnitmclsTbxLabel As MSForms.Label Private WithEvents SpecMinMoymclsTbxLabel As MSForms.Label Private WithEvents

In an Excel UserForm, how do I update a label's caption?

三世轮回 提交于 2019-12-23 10:58:08
问题 I created my first modeless UserForm in Excel and put an ActiveX label on it. How do I set the caption of the label so that it displays whatever is in Sheet1.Range("A1") , and updates itself when the value in cell A1 changes? Basically, I want the Userform's label to always be updated the second anything in the Excel cell changes. Thank you! 回答1: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Cells(1, 1), Target) Is Nothing Then Exit Sub End If UserForm1.Label1.Caption =

Dynamic created User-Form, with 2 dependent Combo-Boxes

孤街浪徒 提交于 2019-12-23 04:26:39
问题 I am trying to create a dynamic User_form, where all the Controls are created at Run-Time. I have 2 array of Combo-Boxes, first array of Combo-Boxes is "Catgeory" ( CatCBArr ) , and the second array of Combo-Boxes is "Item" ( ItemCBArr ). I want, that once I select a value from the first Combo-Box of "Category", let's say CatCBArr(0) , that only the related Items in ItemCBArr(0) will be displayed. Issue : I can't figure out how to modify the second Combo-box ( ItemCBArr(0) ) according to the

VBA function for Controls in Userform

故事扮演 提交于 2019-12-23 01:45:33
问题 I'm very new to VBA so I apologise if the question seems silly: I have set up a UserForm with some controls in it, and created a function called ResetMyField as per below: Function ResetMyField(MyField As Object) If MyField = ProjectReference Then 'do something different and then End If MyField.Value = "" End Function When I call this function using ResetMyField(ProjectReference) VBA comes out with a 424 error (Object Required). Should I be declaring MyField as a different type of variable in

Right to left userforms in excel - VBA

久未见 提交于 2019-12-22 14:17:27
问题 Please Look at the code below and test it: Private Sub CommandButton1_Click() MsgBox "This window converted Right to Left!", vbMsgBoxRtlReading End Sub This code convert the message window from right to left. As the close button moves to the left of the window. How do I do this for userforms? (Hope T.M., Mathieu Guindon and ... does not say: " Your question is amiss. Please read the links ...." ) Like the picture below (Of course photo is photoshop!): 回答1: Simulate Right To Left display as in