Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is xlCellTypeConstants, 22 faster than a loop when deleting?

Tags:

excel

vba

I found a snippet of VBA for deleting rows in which the column value contains text.

It seems to work much faster than a loop statement. I looked online to figure out how Specifically xlCellTypeConstants, 22 works.

[D:D].SpecialCells(xlCellTypeConstants, 22).EntireRow.Delete
like image 396
user8213417 Avatar asked Oct 17 '22 10:10

user8213417


1 Answers

You're providing the first argument as xlCellTypeConstants, so that means the second parameter can be a bitwise combination of:

xlNumbers = 1
xlTextValues = 2
xlLogical = 4
xlErrors = 16

In your case, you're using a hard-coded number of 22, which is the bitwise equivalent of xlErrors Or xlLogical Or xlTextValues

See this article (Archive) for more details.

like image 51
ThunderFrame Avatar answered Oct 20 '22 22:10

ThunderFrame