I'm trying to debug code using "Step into", but first part of my code requires another workbook to be opened by TextBox. So "Step Into" just stops when TextBox appears (I mean that there is no opportunity to choose file via button or fill by keyboard).
Is there another way to debug code step-by-step or way to avoid this stuff?
Thanks in advance!
You can (temporarily) add code to cause a break
Debug.Assert <Some Condition that returns FALSE when you want to break>
eg
Debug.Assert False
Related
I have a lot of macros in my excel. I don't know whether they are used in that workbook. I don't know whether it is called as a procedure inside other macros.
Is there any way to find out whether the macro is used inside another macros or used in different sheets?
Probably the easiest way - Ctrl + F.
Write the name of the "Macro" and select search in Current Project. Then start counting how many times it will show up.
Another way is to write debug.print "I am used" after the Sub line of the "Macro". Then count how many times has it popped up on the immediate window.
put “Option Explicit” at the beginning of every module
comment out your “Macro
start debug
And it’ll point you to any occurrence of “Macro” call
I'm trying to use the Application.Evaluate function to test if a conditional formatting condition is true. However, what is happening is that the macro just stops - no error message, and the cell in which the UDF is referenced returns #VALUE.
The value of the conditional formula Formula1 property in this instance is "=A1<>VLOOKUP($A1,actWOrders1!$A:$EF,COLUMN(A1),FALSE)"
I've tried replacing Application.Evaluate with ActiveWorksheet.Evaluate, in case it is the Application form is struggling with the context, but the same happens.
Any ideas what might be causing the issue?
Thanks! Screwtape.
If your macro doesn't contain any on error handing statements it would certainly provide you with an error message if at any point it was unable to execute. It could be that your macro is executing completely however is not achieving the result you expect.
Try running it step by step using F8 and observing what is happening on each line to find the culprit, as you step through you can hover your cursor over a number of items such as variables to see what their value is. You might also find reading this webpage will help you to use the tools in VBA to debug your macros.
You created a circular reference.
If you try and type the formula into a cell Excel will tell you that has a circular reference.
You can also step through a formula in the formula bar.
Highlight an expression in the formula that you want the value of
Press [F9] to calculate the expression
The expression will be replaced with its value
I have a number of private subs in Sheet code that refer to ComboBoxXX_Click. If I run another macro in the same Sheet that has SheetX.Calculate anywhere in the macro (referring to the sheet that contains the ComboBox) in the VB Editor using the step-into function, when it comes to execute the .calculate line it jumps to the ComboBoxXX_Click Macro. This makes me think that Excel is thinking that the ComboBox is clicked when the sheet is recalculated.
Try a different option instead of ComboBoxXX_Click
I suggest looking at the list of events that can be triggered on MSDN for that control.
try MouseDown
If you could add more information and blocks of code to help us help you. Also have you stepped through your code to find out at what point it is calling the ComboBoxXX_Click?
enter image description here
Here is an example of what I mean. Once the step into hits the Sheet4.Calculate on the first macro it skips to the second one (ComboBox25_Click) and if I step into the second one, once it reaches the Sheet4.Calculate line it also skips to a random ComboBoxXX_Click Macro.
I have a Word 2013 Macro which quickly runs a simple spell check dialogue.
I want to run it every time I type a word.
One way of doing this is by running the macro every time I press space.
Therefore, I tried to use the Options>Customize Ribbon>Keyboard Shortcuts method but that did not work for the space key.
How can I run a macro every time press the "space" key?
Thank you in advance.
You should be able to do this using KeyBindings. I've not tried it with spacebar specifically, but I use this with tab, backspace, etc. The basic idea is:
in a sub that you run at startup or document open:
'This line may differ depending on whether you are running this from a document template or an add-in.
Application.CustomizationContext = ThisDocument.AttachedTemplate
' Create the keybinding.
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeySpacebar), KeyCategory:= _
wdKeyCategoryMacro, Command:="MyMacro"
Then make sure your macro is named to match whatever you put in Command.
I call an Access macro from vb.net like so:
Acc.DoCmd.RunMacro("Macro1")
The Macro in Access has many OpenQuerys and Msgbox with a message saying "data done" at the end.
When I execute the macro from vb.net, it shows the data done message and then done. However, when I analyse the table's to see if data has been appended, it hasen't.
When I run the same macro from within Access, it works fine. It does show many messages like "You are about to run an append query that will modify data in your query" and I hit yes and does take slightly longer, but it does do it.
In VB.NET, the only message I get is the final messagebox.
I have also tried:
Acc.SetOption("Confirm Action Queries", 0)
Acc.SetOption("Confirm Document Deletions", 0)
Acc.SetOption("Confirm Record Changes", 0)
before executing the macro from within VB.NET but to no avail. Still works the same.
Is there a way to fix it?
EDIT: My Access DB is mdb file
I think the problem is with the UI messages in the macro:
It does show many messages like "You are about to run an append query that will modify data in your query" and I hit yes
There's an option in Access to suppress these confirmation queries, you'll want them suppressed in the .mdb file. Looks like attempting to suppress them from VB isn't working.