Why can't I pass a concatenated string as the argument to a particular subroutine I'm using?
In the code below, you'll see that:
1. An event handler makes calls to a subroutine called "DebugMsg" that provides an easy way to turn on and off MsgBox statements used for debugging.
2. Whether or not the messages get passed to an actual MsgBox statement is based on the value of the constant "DEBUG_MESSAGES"
*** For some reason, the one line of code in "CODE EXAMPLE #2" throws an error, but the two lines of code in "CODE EXAMPLE #1" work fine. As far as I can tell, they are functionally equivalent.
*** This variation does not work either:
DebugMsg "NOT Nothing, Target.Rows.Count=" & CStr(Target.Rows.Count)
*** It's understood that in this trivial case for illustration, "Target" passed to the "Worksheet_Change" subroutine should never be "Nothing"
QUESTIONS
1. "CODE EXAMPLE #1" and "CODE EXAMPLE #2" are equivalent, correct?
2. In any case, do you know why "CODE EXAMPLE #2" does not work even though "CODE EXAMPLE #1" does work?
I love Zoho apps and the VBA support in the Sheet tool, but ...
3. Are there any specific plans to improve the VBA debugging process?
- break points?
- single stepping through code??
- variable inspection?? (hierarchical, in the case of types, arrays, objects, etc.)???
4. Is there any way to make a series of MsgBox statements fire individually (like in Excel)?
5. Is it possible to have more than one Macro Module?
6. (inevitably) I've noticed several differences in behavior between Zoho VBA and Excel VBA (and I don't simply mean what Zoho supports versus what Excel supports).
- Is there a document that lists all the known differences?
Thanks!
Matt
'=============== In a Sheet's Code Module =================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim s1 as String
Application.EnableEvents = false
On Error Goto ENEV
If Target is Nothing Then
DebugMsg "Nothing"
Else
'CODE EXAMPLE #1
s1 = "NOT Nothing, Target.Rows.Count=" & Target.Rows.Count
DebugMsg s1
'CODE EXAMPLE #2
'DebugMsg "NOT Nothing, Target.Rows.Count=" & Target.Rows.Count
'END CODE EXAMPLES
End if
GOTO LEAVE
ENEV:
MsgBox "Worksheet_Change Error"
LEAVE:
Application.EnableEvents = true
End Sub
'=============== In "MACROS" Macro Module =================
PUBLIC CONST DEBUG_MESSAGES = TRUE
Public Sub DebugMsg(sMsg as String)
If DEBUG_MESSAGES then
MsgBox sMsg
End If
Goto LEAVE
ENEV:
Msgbox "DebugMsg ERROR"
LEAVE:
Application.EnableEvents = true
End Sub
Sticky Posts
Slicers are now available in Zoho Sheet—filter your data interactively
At Zoho Sheet, we diligently track user requests and feedback. In line with this, based on extensive user requests, we've integrated Slicers to pivot tables and are delighted to announce its release. Slicers are interactive visual filters that have add,
Check out the new Checkbox in Zoho Sheet
Checkbox, the simple GUI widget that lets you choose between two mutually exclusive options i.e Yes or No, is now in Zoho Sheet. Having made it across the web, Checkbox is familiar but is still elusive to most spreadsheet software. Special developer ribbons, macros and all other complexities to add a checkbox to a spreadsheet? Not in Zoho Sheet. How to add Checkbox to Zoho Sheet? Adding a Checkbox in Zoho Sheet is simple. Select a cell/range and choose "Checkbox" in "Input Controls" under the Format
Format and analyze spreadsheet data with Zoho Sheet's Table
While a spreadsheet helps you compile data for easy analysis, formatting helps make your data more comprehensible. We are happy to announce the release of Table, a crucial tool for improving data formatting in Zoho Sheet. More than a formatting tool,
Introducing Data Bars: Graphically represent changes in data within the cells
Conditional formatting has helped millions of spreadsheet users analyze and highlight their data more efficiently. In addition to the classic rules, color scales, and icon sets available in Zoho Sheet, you can now apply Data Bars, a convenient method
Zia in Zoho Sheet now makes suggestions on conditional formats, picklists, and checkboxes
Zia, Zoho's popular AI assistant, has been helping users succeed across Zoho applications since inception. In Zoho Sheet, Zia helps users efficiently build reports and analyze data with recommendations about data cleaning, charts, and pivot table. Also,