userform

Listbox sort/filter by date time in vba userform?

久未见 提交于 2021-01-28 19:14:10
问题 I have a userform with a listbox that displays data from a worksheet. I am wanting to get that data to display in the listbox by current date and time. So when a user enters new data he/she sees the most current lines of data. This is to help the user so they don't enter duplicate information. I am hoping this can be accomplished programmatically because in the near future this form will be linked to a database not a worksheet. Here is the code to populate my listbox: Private Sub UserForm

Return a value from a userform

那年仲夏 提交于 2021-01-28 12:53:45
问题 I am trying to return a value from a userform to another macro. Here is an example of a piece of code that I want to return the value intMonth : sub comparison() UserForm1.Show end sub then I have the userform code: Private Sub initialize() OptionButton1 = False End Sub Private Sub OptionButton1_Click() intMonth = 1 Me.Hide End Sub How do I get the intMonth value of 1 back to my original comparison() function? 回答1: This is a minimal example, but should help. In the UserForm: Option Explicit

Set focus on UserForm Textbox on tabbing from another Textbox

半腔热情 提交于 2021-01-27 16:32:43
问题 I have a Userform in Excel. It has 6 Textboxes, they are the only controls on the Userform with TabStop set to True. I can tab and move through the textboxes. I cannot get SetFocus to work on Events fired when moving between the Textboxes. I can put a CommandButton on the userform with Userform16.Textbox1.Setfocus and it works as expected to move the focus to Textbox1. I set up a simple test event (see below) to move the textbox focus back up to TextBox1 when Textbox2 is entered. It moves

Check if userform open

你说的曾经没有我的故事 提交于 2021-01-27 04:31:08
问题 I run a program which repeats itself. It should stop, when the user closes the userform. It runs without stopping. Since the program calls itself every 8 seconds, I want to check at the end if the userform is still loaded / opened. Public Sub NextPicture1() PictureChange = Now + TimeValue("00:00:08") If Onboarding_Projekt.Visible = True Then Application.OnTime PictureChange, "NextPicture1" End If End Sub 回答1: You can use a function like this: Public Function IsLoaded(formName As String) As

Is there a way to transfer all values from one array to another, then erase the original array?

↘锁芯ラ 提交于 2021-01-07 06:37:18
问题 I'm running into a problem with a block of code I'm trying to develop at my job. Essentially, I'm creating a userform in excel where folks will enter data for railcars as they get loaded at a certain location (we'll call these "spot 1, spot 2, spot 3, etc."). Sometimes they'll have to move that car to a different spot, in which case I want them to be able to keep all the information on the railcar from the first/original entry, and then erase the data from the original spot once that's done.

Is there a way to transfer all values from one array to another, then erase the original array?

元气小坏坏 提交于 2021-01-07 06:36:23
问题 I'm running into a problem with a block of code I'm trying to develop at my job. Essentially, I'm creating a userform in excel where folks will enter data for railcars as they get loaded at a certain location (we'll call these "spot 1, spot 2, spot 3, etc."). Sometimes they'll have to move that car to a different spot, in which case I want them to be able to keep all the information on the railcar from the first/original entry, and then erase the data from the original spot once that's done.

How to add userform into this code instead of msgbox?

隐身守侯 提交于 2020-08-10 19:26:11
问题 I currently have this code Private Sub Worksheet_Change(ByVal Target As Range) Dim myCell As Range For Each myCell In Range("G4:G160") If (Not IsEmpty(myCell)) And myCell.Value <> 17521 And myCell.Value <> "" Then DisplayUserForm Exit Sub End If Next myCell End Sub and have this for my userform Sub DisplayUserForm() Dim form As New WarningBox form.LOL.Caption = "INCORRECT!" form.Show Set form = Nothing End Sub What else must I do in order for this to appear instead of msgbox to alert whoever

VBA Userform: Text of same font size changes size based on Top property

笑着哭i 提交于 2020-08-08 07:45:43
问题 I have a userform. In multiple cases across several different controls, I have observed the objects with the same Width, Height, Font, and Font Size display different font sizes depending on where they are placed on my userform. . . . . Above is an example of this. The two textbox's are both 26H and 48W, with a Left of 90. Both have font Tahoma Regular size 18. The only difference between them is their Top property. And yet visually, the upper one has much wider text than the lower one. The