userform

VBA use global variable in userform code

拥有回忆 提交于 2020-01-16 20:04:06
问题 I'm working in Excel 2010 VBA. Is there a way of accessing values in global variables declared outside a userform, in code inside the userform? Code inside my userform returns the global variable as null - can't work out why! The variable is declared in the ThisWorkbook module as: Public TargetCell As Range Public TargetCellWorksheet as Worksheet Public CurrentValue As Long Inside the userform, I have this code on the "Update" button: Private Sub Update_Click() MsgBox ("Start of Update sub.

Excel Userform Input going haywire

半世苍凉 提交于 2020-01-14 03:17:11
问题 I have the following code for a userform called SlideSorterStart : Private Sub Okay1_Click() Dim startOn As Integer startOn = SlideSorterStart.Input1 Unload SlideSorterStart End Sub Okay1 is the OK button here below, while Input1 is the name of the text box. I use the variable startOn in a module as follows: Sub SlideSorter(ByVal control As IRibbonControl) Dim first As Long: first = ActiveWindow.Selection.SlideRange.SlideIndex Dim last As Long: last = ActivePresentation.Slides.Count

My ComboBox doesn't display the values I've added in VBA

女生的网名这么多〃 提交于 2020-01-11 07:04:54
问题 I'm trying to add options to a combo box in a userform. When I run the code, Excel doesn't give any errors, however when the userform shows up it doesn't display the entities I have added to the combobox previously. That is, when I click on the combobox, it doesn't show any options, only one blank row, as if no items were added to it. Here is the code I'm using: Private Sub UserForm_Initialize() ComboBox1.AddItem "xxx" ComboBox1.AddItem "yyy" ComboBox1.AddItem "zzz" End Sub I am using the

Calculate totals for selected checkboxes in userform using excel VBA

邮差的信 提交于 2020-01-07 09:24:01
问题 I'm Creating an userform with multiple checkboxes, where I want to Calculate/totals for the selected checkboxes and to be displayed in the Userform itself. Actual Userform Code for Estimate button: Private Sub preflight_calculate_Click() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Preflight") With ws LastRow = .Range("A" & Rows.Count).End(xlUp).Row For i = 2 To LastRow For j = 0 To us_mp0.Selected - 1 lbValue = us_mp0.Selected(j) If .Cells(i, "A").Value = lbValue Or _ .Cells(i, "A")

Calculate totals for selected checkboxes in userform using excel VBA

…衆ロ難τιáo~ 提交于 2020-01-07 09:23:11
问题 I'm Creating an userform with multiple checkboxes, where I want to Calculate/totals for the selected checkboxes and to be displayed in the Userform itself. Actual Userform Code for Estimate button: Private Sub preflight_calculate_Click() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Preflight") With ws LastRow = .Range("A" & Rows.Count).End(xlUp).Row For i = 2 To LastRow For j = 0 To us_mp0.Selected - 1 lbValue = us_mp0.Selected(j) If .Cells(i, "A").Value = lbValue Or _ .Cells(i, "A")

Calculate totals for selected checkboxes in userform using excel VBA

岁酱吖の 提交于 2020-01-07 09:23:07
问题 I'm Creating an userform with multiple checkboxes, where I want to Calculate/totals for the selected checkboxes and to be displayed in the Userform itself. Actual Userform Code for Estimate button: Private Sub preflight_calculate_Click() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Preflight") With ws LastRow = .Range("A" & Rows.Count).End(xlUp).Row For i = 2 To LastRow For j = 0 To us_mp0.Selected - 1 lbValue = us_mp0.Selected(j) If .Cells(i, "A").Value = lbValue Or _ .Cells(i, "A")

Listbox populate with specific rows

心已入冬 提交于 2020-01-07 08:06:10
问题 I want to populate a vba listbox from a database only with specific rows. This is what I got. Private Sub UserForm_Initialize() Hoja2.Activate ListBox1.ColumnCount = 5 ListBox1.ColumnWidths = "70;90;90;90;70" ListBox1.AddItem "FIRST NAME" ListBox1.List(0, 1) = "LAST NAME" ListBox1.List(0, 2) = "LAST NAME 2" ListBox1.List(0, 3) = "BORN DATE" ListBox1.List(0, 4) = "AGE" Dim seguimiento As Integer Dim i As Integer seguimiento = Application.WorksheetFunction.CountA(Range("b:b")) For i = 1 To

VBA UserForm Get Filename

十年热恋 提交于 2020-01-07 05:31:12
问题 I have constructed a UserForm that consists of 2 CommandButtons, each of which contains a Picture. The user is asked to select one of the two CommandButtons. I would like the filename of the picture selected to be copied to a cell in a worksheet. At the moment I can't figure out how to get the filename of the picture and so I have manually inserted the filename for each CommandButton, as such: Private Sub cmdQ2Opt1_Click() Worksheets("UserQuestionnaire").Range("C4").Value = "242.216.490" End

Check boxes in user form to select sheets to print

时光总嘲笑我的痴心妄想 提交于 2020-01-07 03:53:21
问题 I have code that selects an array of sheets to be printed to a pdf document, however I am trying to implement a user form with a series of check boxes that correspond to a specific sheets. The following code selects a predetermined array of sheets and prints them as a pdf Sub PDFAllSheets_Click() Dim ws As Worksheet Dim strPath As String Dim myfile As Variant Dim strFile As String Dim sheetstoprint As String On Error GoTo errHandler Set ws = ActiveSheet strFile = "E_CALC_" & Worksheets(

Excel data checking

倾然丶 夕夏残阳落幕 提交于 2020-01-06 15:59:46
问题 Excel data checking I have an Excel UserForm which contains the following fields; date , name and work . In the event that the worksheet contains the same date and name pairing, I want data transfer from the Userform blocked. Example A worksheet has one entry: Column A has the date 1/1/2017 Column B has the name john For the worksheet above, the following rules apply: Information can be passed from the UserForm for 3/1/2017 and john . Information can be passed from the UserForm for 1/1/2017