View Code When Modal Dialog Is Open In Excel - vba

This may be a stupid question, but I feel like I'm in a pickle. I have a modal UserForm that opens when an Excel workbook is opened. When the UserForm is closed, the Excel workbook is saved and closed. I need to be able to view my code, but I can't seem to figure out how to do that because if I close the modal dialog box, the workbook closes. Does anyone know how I can view my code? I really apologize if this is a stupid question, but I can't seem to figure it out.
Thanks for you time and effort.

Without restarting the workbook i.e when the userform is shown in modal, you can use CTRL + Shift + Pause/Break to get into the VBE
Depending on laptops the key combination might change. Here is another which you can try.
Fn + Pause/Break

Hold the shift key when opening the workbook. This allows you to open office applications with macros not running and can be useful in situations like this.
Then view the macros (hit Alt+F11 to open it this editor).

The two other suggestions are good. For easiest debugging, I'd put the code that opens the userform in a separate routine and then call that routine from Workbook_Open. That way you can run and debug your code without having to re-open the workbook.
Then your ThisWorkbook module might look something like this:
Private Sub Workbook_Open()
MyUserformProcedure
End Sub
Sub MyUserformProcedure()
UserForm1.Show
End Sub
You could then comment out the line in Workbook_Open and call MyUserformProcedure, and uncomment the line when you're finished debugging.

Related

Prevent excel from closing when closing userform

I hope you can help me with this issue, I couldn't find any answer nor on google nor here. So here's the point:
I have to userforms. One of them opens on Worksheet_Open. In the Background I can still see the worksheet and the excel application. But when I click outside of the userform or close it, the application window disapears too. But in the open processes I can still see excel open.
My intention is to have the Excel window always open (in the background) so that when I close the UserForm the Excel Tables will be visible.
What do I have to code for that? To hide the userform didn't work for me...
Thanks in advance.
Hi there if you want to use both excel and your Userform at the same time then go to your Userform property and make ShowModal = False

excel not responding after closing Find menu that is opened with vba

I have created a button in a excel sheet that opens the Find menu (ctrl+f).
Sub Button6_Click()
Application.Dialogs(xlDialogFormulaFind).Show
End Sub
After the search is done and one closes this menu excel doesn't respond anymore and closes itself. Any ideas why?
Also, I don't get the exact same find dialog as when I use ctrl+f. Is there maybe a way to use keyboard-functions in vba?
Why not use ctrl+f instead of the button. Because my colleagues are not quite good with excel and that already is too much to remember for them :)
This is how to mimic a key press in VBA ^ is Ctrl
Sub Button6_Click()
Application.SendKeys ("^f")
End Sub

MS Excel User forms vba

Hi "im kind of new with excel VBA. I'm trying to do something simple as creating a USERFORM1 in VBA and showing it when workbook opens. I've looked it up online but for some reason something is not working.
I open excel, go to developer, create a userform1, add some stuff to it.
I open code for THISWORKBOOK and under Open procedure I type
Private Sub Workbook_Open()
UserForm1.Show
End Sub
Then I save it as Macro Enabled and when i open it, nothing happens. What is going on? I know this is a silly question but am i doing something wrong?
In trust center I didn't have macros enabled. I did that and everything seems to work perfectly.

Progress Bar in Excel using VBA and userForms

so I've been looking and cant find anything on this, I hope someone can help.
what I am trying to do:
I want to create a progress bar for my excel workbook that I am making. in order to accomplish this I have created a user form with data fields that I can manipulate from outside of the userform. what I would like to do is to load the userform from inside a module and then from the same module update the userform as the module continues to run.
is there a way to do this?
currently when I use userForm1.Show it displays the userform, but the control never goes back to the calling module, and the code ends when reaching the End Sub for Private Sub userForm1_Activate()
any help would be appreciated.
thank you
You are opening the userform as a modal form. To return the control back to the calling module, you must open the userform modelessly:
UserForm1.Show vbModeless

Excel macro - open macro without going into Visual Basic?

I've finished my macro! But is there an easier way in runnning it?
I know two ways
Open Visual Basic, select the correct macro and run!
View Macro's, select the correct macro and run!
Is there an easier way, or are these the only two ways?
Thanks
Place a command button on your sheet, view its code in the VB editor, and edit it so it looks something like this:
Private Sub CommandButton1_Click()
Call MyMacro
End Sub
You can then just click your button every time you want to run your macro.
you can even create little smiley icon in your Toolbar so that it stays there and you can run it by clicking it or have shortcut keys attached to it.
There are several options:
Toolbar or Menu (Excel 2003 & earlier)
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-toolbar-or-menu/
ActiveX control
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-an-activex-control/
Button (Forms menu control) or Shape
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-button-or-shape/