Is there an equivalent to python "pass" in VBA to simply do nothing in the code?
for example:
For Each ws In ThisWorkbook.Sheets
If ws.Name = "Navy Reqs" Then
ws.Select
nReqs = get_num_rows
Cells(1, 1).Select
If ActiveSheet.AutoFilterMode Then Cells.AutoFilter
Selection.AutoFilter
ElseIf ws.Name = "temp" Then
pass
Else
ws.Select
nShips = get_num_rows
End If
Next
I get an error here that pass is not defined. Thanks.
VBA does not have a specific statement that can be used for 'doing nothing'. Unlike Python, which has a pass statement that can be placed where we do not want to take any action, VBA does not use such a statement.
The VBA programming language allows users to access functions beyond what is available in the MS Office applications. Users can also use VBA to customize applications to meet the specific needs of their business, such as creating user-defined functions, automating computer processes, and accessing Windows APIs.
nothing is a literal identifier that is only applicable to variables that are declared as objects or variant. The value nothing represents an object whose object reference (which seems to be a memory address) is 0. An object variable is considered nothing if its reference count is zero.
just remove pass
and re run the code. VBA will be happy to accept that I believe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With