How To Make VBA Editor Show Userform Code By Default
Apr 25, 2014
When you create a userform in the vba editor, then go to another module, then return to the userform, you see the userform object by default and in order to show the code you have to right-click on the userform and select "view code".
How can I make the "view code" view the default view for the form in the VBA editor? (i.e. so that when the form is selected, I am presented with the code, not the object).
I have a spreadsheet on sheet 1 with a list of customers and their information. So on column A I have the customer number (i.e. k968, e37, p528,...), on column B i have the customer's name, on column C the street's name, on Column D the house number, on column E the zip code and finally the city on column F.
Right now there are around 600 customers in this list.
I have made a userform with a combobox in which I want to select an existing customer (pulled from the spreadsheet). On the same userform I have textboxes (customer number, name, street, number, zip, city). When I select a customer in the combobox, I want this customer's info to show up in the textboxes. I want to be able to change the info and hit Next to store the changes in the spreadsheet. When I do not select a customer from the combobox, I want to add new info in the textboxes and hit Next to store this info as a new customer. The userform also has a delete button. Then I select a customer in the combobox, this customer (and it's info) should be deleted from the spreadsheet when i hit Delete. So the spreadsheet is variable in length.
Is it possible to check, with VBA code running some sort of "If" function in the background in an open workbook within which the VBA code is placed, whether a user is opening (or attempting to open) the VBA Editor? This should see any attempt being made, whether the user uses Tools>Macro>Visual Basic Editor, Alt + F11 or right clicking on the Excel icon top left to "View Code".
I am using the following Selection_Change Event to show a UserForm when a cell in 1 of 31 named ranges is selected.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count > 1 Then Exit Sub Dim i As Long
For i = 1 To 31 If Not Intersect(Target, Range("StatPost" & i)) Is Nothing And Target.Value = "" Then If Target.Offset(0, -8).Value = "" Or Target.Offset(0, -7).Value = "" Or Target.Offset(0, -6).Value = "" Or Target.Offset(0, -5).Value = "" Or Target.Offset(0, -3).Value = "" Or Target.Offset(0, -2).Value = "" Or Target.Offset(0, -1).Value = "" Then....................
I like to make my numbers with no decimals, with a comma. This means I have to constantly press a number of buttons to put them in the format I want. Not too big a deal but is there a way I can make one of the buttons in the number group default to the way I want the numbers to appear?
i changed the shape of "Comment" box with edit shape. However when i right click the updated shape and click on Set Autoshape Default it does nothing. When I insert a new comment it is back to old shape.
1. Is it possible to have two versions of excel installed on the same PC and would this cause any issues? This would be my preffered approach as it would enable me to do the haevy number crunching in 2007, but use 2000 for the everyday spreadsheets that I would have to share with my collegues. 2. Can you make 2007 default into compatability mode so that I wouldnt accidentaly create a spreadsheet that other couldn't use.
I am having a little bit of difficulty find ways to effectively incorporate a checkbox panel into a form interface. What I am trying to do is all the user to select using checkboxes which of 31 separate columns will automatically be deleted or not deleted. The method I have been using is to create 31 checkboxes, and then use the value of the checkbox (true/false) to determine a value in an array, which then can be used to delete the column by a separate sub.
However, I am interested in being able to have the checkboxes start checked or start unchecked by values contained in a different array. My problem is that I am unable to reference the checkbox itself until the form containing the checkbox is opened, but at that point I don't know of a way to cause the desired checkboxes to automatically be selected without placing a command button that must be pressed to fill them in. Essentially I want to be able to open a userform that has checkboxes preselected.
I have a userform with 10 textboxes which will all contain a time in HH:MM format. Could I have the userform to fill the textboxes with a default value once a time has been entered into textbox1. I would like the default value to be the time from the previous textbox plus 30 mins.
eg. So if I enter 14:00 into textbox1 I would like textbox2 to display 14:30, textbox3 to display 15:00.
If this is possible, could I add a Listbox with the options 1 to 10. Then would I be able to only uses the textboxes based on the number selected in the listbox. So if I selected 2 then just Textbox1 and Textbox2 would have values in them. For 8 being selected then Textboxes 1 through to 8 would be filled.
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Application.ScreenUpdating = True Unload Me RestrictedOptions.Show Else Cancel = True End If End Sub
Trying to use above code to unload active userform and show new userform when red X (close) selected by operator. With the code as is, the Unload Me leaves the form on the screen and displays the RestrictedOptions form. If i remove the Restrictedoptions.Show, the Unload Me does remove the original form.
I am trying to do, is make a drop down list show the picture above it. I have tried to change everything, and I am sure I am just a hair away from getting it right. I got the spreadsheet to where it will pull up the "Picture #" in the appropriate box, and even had it delete/hide all my pictures (I say delete/hide because I couldn't get them back after I removed the coding I was working on).
Another nice function I would like would be a button, around cell B74, to erase all the picks and reset the sheet for the next season... it would have to have a prompt to verify the user was absolutely sure they wanted to do that though! But I don't know where to begin on that button issue. Can someone point me in the right direction?
The spreadsheet is too big to attch, so it's hosted at the link below. The sheets involved are NFL Survivor & PicTable. On sheet PicTable, the Names & Pic #'s have already been named PicTable for ease of coding.
In the attached file (xlsx) under 'Database' Tab poeple have indicated their preferences (multiple choices) for different food items "specialties". The specialties are grouped under broader buckets called "groups". The specialties are bucketed into groups in a way that people end up more than once in each specialties and groups due to their muliple selections. When we create a pivot by specialties (Pivot Specialties tab), each person appears only once for each specialty...it's great. But, when we create a "group" pivot (each group has multiple specialties), now, people appear more than once for each group. Is there a way, each person can show up only once under each group so the group count does not appear to be misleading?