userform

UserForm Close Event

旧时模样 提交于 2019-12-12 12:23:31
问题 I have a UserForm which is opened and closed in a loop while a condition exists. The users can click several buttons which performs an action. The problem is the unpredictability of users. One of those problems is, users, instead of clicking one of the buttons, clicking the close window button on top of the UserForm which progresses the loop without performing an action. --- edit--- Is there an event with that button with which I can execute code so that I can let it perform the same action

Excel VBA Textbox time validation to [h]:mm

泪湿孤枕 提交于 2019-12-12 12:21:31
问题 I am developing a VBA Excel Userform and need to enter a time in the [h]:mm format. This means that the hours can be unlimited and does not cycle back to 0 after 23:59 like the hh:mm format does. I have searched the web to no avail. Here is the code I'm currently using: Private Sub Txtbx_TimeAvailable_Exit(ByVal Cancel As MSForms.ReturnBoolean) If Me.Txtbx_TimeAvailable.Value <> Format(Me.Txtbx_TimeAvailable.Value, "[h]:mm") Then MsgBox "Please enter correct time format in hh:mm" Cancel =

How to clear an Image in a Userform?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 07:05:21
问题 I have a Userform in which I use an Image field. I display a picture in this field, based on two criteria. I don't know how to clear this Image in the Userform when I want to type two new criteria. 回答1: You can easily 'clear' your UserForm Image control (e.g. Image1) via Image1.Picture = LoadPicture(vbNullString) . In the example below you would switch between showing a defined picture and displaying the empty control when clicking your command button. In order to control the Image status

Excel vba list box multi column multi row from 14 text boxes

别等时光非礼了梦想. 提交于 2019-12-12 06:42:21
问题 I have user form with 14 text boxes , 2 command buttons " next " , " Post " and 1 list box I need code to get the data from the 14 text boxes to the list box , again when the user enter new data and press next this data added to second row in the list box , gain , again finally when he press post all data move to work sheet " Database" Sub CommandButton1_Click() Dim arr1, i As Long Dim arr2(0 To 0, 0 To 13) arr1 = Array(TB10, TB10, TB0, tb1, cb1, cb2, tb5, tb4, TB10, TB10, TB10, tb6, tb7, tb8

Event handling class doesn't fire unless I break userform initialization

我怕爱的太早我们不能终老 提交于 2019-12-12 04:54:44
问题 This is a follow-up to the following question: Can't set Userform.KeyPreview to true To recap: the goal is to build a form with some command buttons and a frame containing check boxes. The check boxes are dynamically populated at userform_initialize in the frame so the user can scroll through them. My problem was with keyboard shortcuts. It wasn't possible to brute force write KeyDown handlers for each of the checkboxes because I don't know which ones will exist. Unfortunately, Excel doesn't

Specific workbook invisible Excel VBA

时光毁灭记忆、已成空白 提交于 2019-12-12 04:23:07
问题 I am writing a script in Excel VBA where the Workbook is supposed to open with a UserForm . I want only the UserForm to be visible and the excel window itself to be invisible. As such, I have written the following code for the opening of the Workbook : Private Sub Workbook_Open() 'Application launch Application.Visible = False 'Hide Excel window EnableResize = False Application.DisplayFullScreen = True 'Preset fullscreeen mode Application.CommandBars("Full Screen").Enabled = False 'Hide

Loop Updating Chart Image on Userform

五迷三道 提交于 2019-12-12 03:47:47
问题 Okay, So I am trying to integrate the following code: `Private Sub UserForm_Initialize() Dim Fname As String Call SaveChart Fname = ThisWorkbook.Path & "\temp1.gif" Me.Image1.Picture = LoadPicture(Fname) End Sub Private Sub SaveChart() Dim MyChart As Chart Dim Fname As String Set MyChart = Sheets("Data").ChartObjects(1).Chart Fname = ThisWorkbook.Path & "\temp1.gif" MyChart.Export Filename:=Fname, FilterName:="GIF" End Sub` from this post: Displaying "live" chart data in Excel Userform into

Global VBA date format and decimal separator

此生再无相见时 提交于 2019-12-12 03:37:54
问题 Is there a way to change VBA settings globally on PC to accept dates and number on a specified format? (on my case dd/mm/yyyy and comma) Changing Excel settings doesn't solve it for me. As an small time VBA developer, I'm mostly creating userforms for data input and validation. Alongside with some basic access privileges, It keeps users (mostly an client's hired arms) from nosing on the database and corrupting it. But, on form's submitting, the textbox values are saved temporally on

VBA-Excel : Conditional message box popup every 2 minutes from NOW

孤人 提交于 2019-12-12 01:57:57
问题 I have been trying to work things out with NOW (Date/time) but have been unsuccessful. Checkbox1 when True captures NOW in textbox1. From the value in textbox1, every 2 minutes i need a popup message reminder with OK as acknowledgement until checkbox2 is True. Can someone help with this logic and code? Thanks. Dim X1 As Date Dim X2 As Date Dim X3 As Date Dim X4 As Date Private Sub CheckBox1_Click() X1 = Now If CheckBox1.Value = True Then TextBox1.Value = Now Call function01 If CheckBox1.Value

Formatting User Form Controls

怎甘沉沦 提交于 2019-12-12 01:52:29
问题 I am trying to format controls on each of my User Forms similarly, but what I have formats all controls on a User Form instead of just the labels or just the textboxes. Here is what I have: Private Sub UserForm_Initialize() FormatUserForms UFNewRequest End Sub Sub FormatUserForms(UF As UserForm) UF.BackColor = RGB(51, 51, 102) For Each Label In UF.Controls Label.BackColor = RGB(51, 51, 102) Label.ForeColor = RGB(247, 247, 247) Next For Each Button In UF.Controls Button.BackColor = RGB(247,