This question already has answers here:
How can I save VBA watches manually or add them via code?
(2 answers)
Closed 9 months ago.
I've been learning all the nifty tools I have to debug in the VBA editor for excel, but I can't figure out if there's a way to have watches stay set for a project even if its closed/reopened until I remove them. Im doing a lot of stepping-in, etc. while Im learning, and while having watches really helps, its annoying that every time I close/open a file, I have to reset all the watches. This is really annoying when I have several variables I want to keep track of while debugging, say, a Workbook_Open event and I'm closing/opening a lot!
Is there a way to turn on watches for a module or project so they come back on when the project is closed and re-opened? Or do I have to set them manually every...single...time...?
I have a similar requirement.
My proposal was "print" variables in columns in new sheet [with name LOG]. I can save values / times and result and shared that with my team.
Steps:
Define breakpoints
Insert new line in LOG sheet
Save Values and date time
Compare results
Regards
Related
I only have one machine and want to save some variable values like a = 3 in linux. I can resume the last progress if power-off suddently happens.
I can only figure out two ways, one is to save in files and the other one is save to DB.
Are there any special ways to do like this without saving in files or db? any programming language is ok.
I guess there is some confusion. Do you want to save the state of your program? If so then use text editor which saves your progress even if you don't save it using ctrl+s, like sublime or gedit. Otherwise please elaborate more on what you want.
This is my first post, so please be kind.
I have an Excel 2010 VBA macro inside File1.xlsm, which needs to open a second Excel file, File2.xlsx, wait for the second file to be manually edited by the user and closed before it continues. I have no problem opening the second Excel file, but have not been able to figure out how to get the macro to wait until the second file is closed to continue.
Having done some research on this, I tried to adapt suggestions from other similar posts that used Sleep/IsFileOpen in a loop or brought up a message box or user form to temporarily halt processing of the macro. In all of those cases, the second file was opened, but focus was always maintained on the first file that contains the macro. The end result is that I had to close the user form or message box without being able to edit the second file. In the case of the Sleep loop, the Sleep caused all of Excel to Sleep and the application went into an infinite loop checking to see if the file was still open followed by sleeping for 1 second.
Sorry in advance, but the complete listing exists in a closed space and is too complex to re-create here for posting.
I thought this would be simple to start a macro running, have it open a second Excel file, have the user edit/save/close the file and then continue the macro using the updated file. Any suggestions would be appreciated.
I want to use vbs file - which will fire different macros at different hours. I was thinking about putting it in the windows startup programs folder
The point is I want this vbs to fire each of these macros in different hours (Let's assume I will have machine on long enough).
I tried to make separate vbs files for each macro and launch it with windows scheduler. It works, but i dont like this solution and I want to learn smth. To be clear what i want to achieve is:
Launching Computer at 12 -> VBScript is launching at windows start,
then it fires:
Macro a at 13, and update it on 13.15
Macro b at 15
then Macro c at 16 using data from Macro b, and then closing itself
(both macro and vbs).
OFC i will launch computer and close it manually :)
Thanks,
Dawid
You should be able to do this using the timer function which returns the number of seconds since midnight.
https://msdn.microsoft.com/en-us/library/office/gg264416.aspx
To ensure it's not checking every second try the Wait function as well.
https://msdn.microsoft.com/en-us/library/office/ff822851.aspx
I'm still new, so hopefully someone else will expand on this for you, but it should be a good starting point.
I need to create a button in Excel that opens a dialog box and I select the file that I recorded on the second sheet, but I also automatically select other files with the same name differs just ending. So I need to choose one file, and always record 2-3 more with the same name and to open a new worksheet. How to do it?
What you need to select the file abc.txt and uploaded to other files abc.ydd and abc.dyk name will always be the same only the ending will be different.
An advice for any work you are doing: Break down your big task into small steps as often as needed until the steps are small enough so that you know how to process them.
On your specific programming task, this means, you should break it down into:
You need a button on one of the excel sheets.
That button has to open a dialog box for selecting a file
I don't know whether it can be any arbitrary file or a specific one, as you wrote that the file was recorded on another sheet. I think that makes no difference at all.
After finishing the file selection, you have to evaluate the result of the dialog box (OK -> which file, ABORT -> do nothing).
Take the file name, remove the extension and search for other files (in the same directory or elsewhere) with that name.
I don't know why you want to open another worksheet. Of course you can do that, but if you want to show the content of that files in the worksheet, they better be excel files.
How you do these suggested steps is something you need to find out by yourself. Or you are lucky and find someone else who has plenty of free time to do that for you, but I don't think you will be that lucky, especially after providing a quite vague description of your problem.
In general, stackoverflow is for asking for solutions to specific programming problems, not for providing ready-to-use solutions for beginners. Take a look at VBA manuals and tutorials. They can be found widely across the internet and in book stores.
I need to test a very long program that takes many decisions based on live data from an online database. So it is unfeasible to use step in (F8) for an entire run of the program.
I was wondering if there was a way of setting a breakpoint on EVERY line of code of the project. Then when I have tested that line I can clear it and keep running. At the end I will know what part of the program was not tested because it will still have break points.
Any ideas on how to SET EVERY LINE OF A VBA PROJECT TO A BREAKPOINT?
This is not a feature of the VBA Editor. Instead use "Watches"