userform

Difference between declaring a userform as Object vs MSForms.Userform?

风格不统一 提交于 2019-12-07 05:30:19
问题 Just a question that I can't seem to find an answer on. I'm programmatically creating a userform, and I've found if I declare my object as the type "MSForms.Userform" there seems to be no way to set the height and width, as these properties don't exist, and insideheight / insidewidth are read only properties. What I found was if I declare it as the generic type "object", I can set the height and width properties and use it exactly as I want. So, after I initialize the object, I checked the

Why UserForm is “Not Responding” During Run Time in VBA Excel?

五迷三道 提交于 2019-12-07 00:33:30
问题 I'm very new with VBA Excel and i only know the things as far as i need for this report formatting task. I'm almost done with my task but when i run the program and start the progress, eventhough it works successfully, GUI is not responding for a minute. I share my code here, is something wrong with it? Can you suggest me any best-practice? I don't want it to freeze because it will look bad to my manager. Just to make it clear, by "not responding" i mean it freezes on the screen and says "Not

VBA function for Controls in Userform

梦想的初衷 提交于 2019-12-06 17:54:25
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 the function? Both the function and the point at which I call it are inside the Userform module. Any

Conditional Formatting VBA

▼魔方 西西 提交于 2019-12-06 15:39:54
问题 I am building a form to enter account information and order status. Each row needs to change based on the value of one of the cells on the same row, on this case cell "H". I can easily achieve this with conditional formatting but I think this makes the file bigger than programming code. I have tried some options but I can tell at this moment I'm way lost. I am attaching an example of what I want to accomplish. I don't know what to do at this point so if someone can help me I would really

Global Variable in Userform

冷暖自知 提交于 2019-12-06 15:14:31
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 this? Thanks. First Form Private Sub CommandButton5_Click() Db = "C:\Users\Desktop\db.txt" Set File1 =

Excel VBA add code userform programmatically

Deadly 提交于 2019-12-06 15:09:39
问题 I got a tricky issue with my VBA-code. The situation is that I have a manual created userform. I add controls to the userform with a macro and it works fine for me. But now I also need to add event-code to the userform. Following code I want to add with .CodeModule.InsertLines . The important part is that the textboxes, which I want to call should work variably, but it doesn't work, any ideas how to fix this? (Textboxes are named like this: textbox_0, textbox_1 and following) Dim iMaxColumns

How to have VBA code wait until vbModeless userform is closed

心已入冬 提交于 2019-12-06 09:43:23
问题 I'd like to use a formless userform so the user can navigate the excel sheet before answering the question on the userform. I need to pause or loop the code until the userform is closed (hidden or unloaded). Similar issue to this: How can I wait for a specific code to run while when form is closed and is set to vbModeless? but the solution here does not work for my application; My userform is opened in the middle of a long subroutine which needs to finish executing after the userform is

VB right click copy/paste in multipage

江枫思渺然 提交于 2019-12-06 02:26:12
Let me preface my question with the fact that I am self taught, so please provide as much detail as possible and bear with me if I need you to explain differently or multiple times. I created a notation/email generating tool for my team using Microsoft Visual Basic 7.0. The only complaint that I received on it was that many of them are not used to hot keys so they depend on using the mouse but right click didn't work. I was able to find code that creates a pop-up for copy and paste when they use right click, and it works great on the few textboxes that are on the main form itself, however it

Difference between declaring a userform as Object vs MSForms.Userform?

巧了我就是萌 提交于 2019-12-05 11:15:33
Just a question that I can't seem to find an answer on. I'm programmatically creating a userform, and I've found if I declare my object as the type "MSForms.Userform" there seems to be no way to set the height and width, as these properties don't exist, and insideheight / insidewidth are read only properties. What I found was if I declare it as the generic type "object", I can set the height and width properties and use it exactly as I want. So, after I initialize the object, I checked the locals window and the difference seems to be: When declared as type "object" it will initialize as an

Excel - VBA : pass variable from Sub to Userform

大憨熊 提交于 2019-12-05 04:24:13
I have read and applied solution I found on similar topics but nothing seem to work in my case. So, I want to pass a variable from one sub of my Module1 to a userform. It's a string called "provinceSugg". Here is the relevant part of my code : Public provinceSugg As String Sub probaCity() [...] If province = "" And city <> "" Then provinceSugg = sCurrent.Cells(p, db_column).Offset(0, 1).Value UserForm2.Label1 = "Do you mean " & city & " in " & provinceSugg & " ?" UserForm2.Label1.TextAlign = fmTextAlignCenter UserForm2.Show Else End If End Sub And then in my userform code : Private Sub