Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do nothing in vba

Tags:

excel

vba

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.

like image 637
Rik Avatar asked Oct 17 '17 17:10

Rik


People also ask

How do you write do nothing in VBA?

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.

Can you do anything in VBA?

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.

Is nothing is something VBA?

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.


1 Answers

just remove pass and re run the code. VBA will be happy to accept that I believe

like image 61
itChi Avatar answered Oct 17 '22 21:10

itChi