Evidently, you're not the ONLY one wondering about Debug.Assert!
I just responded to another query about the same thing!
I included it here too, just for future reference.
 
As for:
If ((ActiveSheet.Range("A1").Value & "X" = "X") _
And (ActiveSheet.Range("B1").Value & "X" <> "X")) then
 
I suppose this could be considered a "programmer's quirk".
I've spent WAY too much time debugging macros that are producing unexpected 
results,
 only to find that my source data contains a "null" character.
I test something like:
If (Range("A1").Value <> "") then
 
I'm looking for something with a value, but VBA says there IS one.
But the data LOOKS like it's blank... so what's the deal?
Well, a "null" character is an actual CHARACTER ( char(0) ).
 
so, when I checked: 
If (Range("A1").Value <> "") then
it was saying that there WAS a value...
 
To get past that, I started "concatenating" an "X" to the value.
oddly enough, VBA decides that "null" & "X" = "X"
so, I use things like:
Range("B1").value & "X" <> "X"
 
I've done it so often that doing something like:
Rang("B1").Value = "" 
just FEELS wrong, even though it's not
(but it still makes me itch)
 
 
 
========================================
Debug.Assert:
========================================
When debugging a large/complex macro, it's often helpful to use "breakpoints".
(do you use breakpoints?)
Breakpoints:
you select a line and hit the "hand" icon or simply click in the left-hand 
border in the editor.
I've often had SEVERAL breakpoints in a large macro.
But, when you save and exit your workbook and return, the breakpoints are 
GONE!!!
Also, I've often used a technique in which I'm processing thousands of records 
and I want to pause at record #999 or when a value is something specific so 
that I can step throught the code to see what's going on.
In a case like this, using 
Debug.Assert False

is like a "conditional breakpoint"
It PAUSES the macro, just like a breakpoint.
Debug.Assert True passes through and does nothing.
What I've done on large macros is use a "BreakFlag", and:
Debug.Assert BreakFlag
whereever I need a breakpoint.
Then, when record # or value = what I'm looking for, I set BreakFlag = false.
Then, to continue without further breaks, simply set breakflag = true and run!
I use it a lot when I'm testing code for these user groups, then remove them 
before posting.

Paul
-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------

 From: Mandeep Baluja <rockerna...@gmail.com>
>To: excel-macros@googlegroups.com 
>Sent: Friday, November 21, 2014 11:25 PM
>Subject: $$Excel-Macros$$ Re: VBA
>  
>
>
>Hello Paul, 
>
>
>First I would like to thank you from bottom of my heart for making such an 
>efficient code to handle such a bad formatted data. Today I got to know that 
>experience pays off you're brilliant in your efforts. As I have 4 months of 
>experience in VBA Still I understand every line of your code except this , 
>Debug.assert = True , If ((ActiveSheet.Range("A1").Value & "X" = "X") _
>And (ActiveSheet.Range("B1").Value & "X" <> "X")). 
>
>
>if(Query = True, " Paul will handle it,"" Paul will handle it") :P 
>
>
>Cheers 
>
>
>Regards,
>Mandeep Baluja 
>
>
>https://www.linkedin.com/profile/view?id=312532939
>https://www.facebook.com/VBAEXCELSQL?ref=hl
>
>On Thursday, November 20, 2014 4:59:00 PM UTC+5:30, Mandeep Baluja wrote:
>Dear All, 
>>
>>
>>I need to work on Data sheet which contains all the cells in text format. 
>>basically its a timing sheet. I want to change the format of all the time 
>>values in correct format and wish to highlight those cells where people come 
>>after 10:00 am .Hope you can understand this by going through the 
>>sheet.Looking for a Macro which can correct the format of time automatically. 
>>
>>
>>Regards, 
>>Mandeep Baluja
-- 
>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
>2) Don't post a question in the thread of another member.
>3) Don't post questions regarding breaking or bypassing any security measure.
>4) Acknowledge the responses you receive, good or bad.
>5) Jobs posting is not allowed.
>6) Sharing copyrighted material and their links is not allowed.
> 
>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to excel-macros+unsubscr...@googlegroups.com.
>To post to this group, send email to excel-macros@googlegroups.com.
>Visit this group at http://groups.google.com/group/excel-macros.
>For more options, visit https://groups.google.com/d/optout.
>
>
>    

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to