userform

Locate Folder Path Based on a Cell Value with a Combo Box

纵然是瞬间 提交于 2019-12-08 14:38:11
问题 I have an issue in VBA, i want to get the path of a folder based on a combo box value. See, i have an excel sheet called "TAG" where in his first column i have a lot of values, like P36300000, C36300001, etc. (Image Below) I have created a macro that loops through the sheet column and creates a folder based on each cell value. The "P" means that it's the Primary item , and the "C" means that it is just a component of that Item . i.e, it creates the P36300000 folder which contains: 3C6300001,

Application.OnTime doesn't work with userform

梦想的初衷 提交于 2019-12-08 13:15:10
问题 I've got a problem with a piece of code: Private Sub cyclic() Static i As Integer i = i + 1 Cells(i, 11) = i Open source For Append As #1 Write #1, Cells(i, 11) Close #1 Application.Wait (Now + TimeValue("0:00:01")) Open source For Input As #1 Do While Not EOF(1) Input #1, x1 Loop Cells(i, 1) = x1 Close #1 Application.OnTime Now + TimeValue("00:00:03"), "cyclic" End Sub It's pretty much like this. It works perfectly from the level of worksheets alt+f8 macros, but when I want to make use of it

VBA: Multiple Userforms Referencing Same Code

不打扰是莪最后的温柔 提交于 2019-12-08 13:09:01
问题 I have a VBA code that takes user inputs (criteria) via a userform, creates a list of items that meet said criteria, and randomly outputs one of the list items via message box. I want to create a second userform that will open after the above code completes, and have the userform display the random output. I have a few questions regarding how this can be done. I want to the second userform to contain a label, whose caption will reflect the random output. I want the second userform to allow

How to create a macro that will open a userform from an Add-in without opening the workbook

╄→гoц情女王★ 提交于 2019-12-08 12:20:49
问题 I developed a userform that queries the form's workbook for information. I want this userform to be available in other workbooks so users can lookup information in the form's workbook while working in their own workbooks. Originally I tried using this on opening the workbook: Application.visible = False Userform.show vbmodeless However, this will hide all other workbooks in excel which will confuse the user. I then tried saving the userform workbook as an excel add-in and created a macro in

How to make a Search Filter in Excel VBA that displays search result in the ListBox while typing a word?

穿精又带淫゛_ 提交于 2019-12-08 11:03:50
问题 I'm trying to make an Advanced Search now for weeks in my Userform where it will filter and display the result on the ListBox while typing a value. But somehow my ComboBox that serves as a filter has a dropdown function already. I have no idea how can I make it like the way I wanted it. My UserForm contains 8 columns. Here is the existing code for the ComboBox filter Private Sub cmbSearch_Change() 'The function of this code below is for the user to click a value from the ComboBox and then the

Re-Focusing on an Excel Userform ComboBox

岁酱吖の 提交于 2019-12-08 09:43:53
问题 A User is Entering Data into the Edit Region of a ComboBox The ComboBox's Change Event is used to run the following Code; AppActivate "Microsoft Excel" : 'Do some stuff : UserForm1.Show UserForm1.ComboBox1.SetFocus This works OK, BUT; even though the ComboBox now has the Focus again (according to the Userform.ActiveControl anyway), it has no Insertion Pointer to indicate this fact, and the User has to Re-Select the ComboBox before he can continue entering Data I would like to have it so that

Can't get listed of selected items from multiselect ListBox in Excel userform

无人久伴 提交于 2019-12-08 09:37:00
问题 New to VBA and having some difficulty getting selected items from a ListBox. I keep getting an error on the For line. The name of the ListBox is correct and I think .ListCount should work. Sub GetListBox1() Dim SelectedItems As String For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected = True Then SelectedItems = SelectedItems & ListBox1.List(i) End If Next i Debug.Print SelectedItems End Sub 回答1: Try the code below, switch "UserForm1" with the name of your form. Dim SelectedItems As

VBA UserForm gives run-time error 91 for one of its parameters

走远了吗. 提交于 2019-12-08 04:43:14
问题 I am trying to create multiple instances of the same modeless UserForm in excel-VBA, with parameters, through a Sub. I can make it work with two of the three parameters I want to assign, but the third one keeps returning me "Run-time Error '91': Object variable or With block variable not set" and I can't figure out why. It may be an obvious typo that I didn't see, but I really can't point out the problem. Here is my code: Sub AskToClose(targetWksht As Worksheet, targetRow As Integer, test As

Global Variable in Userform

心已入冬 提交于 2019-12-08 02:32:11
问题 I search about this in the forum and found some answers but did not work for me. I have two UserForms. In the first one, I give a value to a variable called Word. In the second one, I have a Label that I need the caption to become the variable Word. Example: Public Word as String Private Sub Userform1_Activate Word = "Today Is Saturday" End Sub Private Sub Userform2_Activate Label1.Caption = Word End Sub But this does not work. The Label caption gets Zero for value. Could anybody help me on

Calling an Array Upon User Form Terminate/Close VBA

拜拜、爱过 提交于 2019-12-07 13:13:32
问题 I have an issue where I'd like to store the contents of a userform in an array when the userform is closed. I thought I had the syntax correct but it seems not to repopulate upon userform initialize. I tried putting the array in its own module and this did not work either. Anyone care to enlighten me? Sample code: Public Sub DPArrayStuff() Dim DP(2) DP(0) = Block1 DP(1) = Block2 DP(2) = Block3 End Sub Private Sub userform_terminate() If Block1.Value <> vbNullString Then Call DPArrayStuff End