Home > Blockchain >  how can i interpret this code?(related to trim)
how can i interpret this code?(related to trim)

Time:04-09

I don't know how to interpret code below

If Cells(iRow, iCol).Cells.Count = 1 And Trim(Cells(iRow, iCol)) <> "" Then

I cannot understand after "and trim~". Can anyone explain this to me?

CodePudding user response:

The Trim function removes spaces in the beginning and end, so in English Trim(Cells(iRow, iCol)) <> "" would be something like remove the spaces before and after and check if the result is different than an empty string. In VBA <> means 'different than' and "" is an empty string.

Personally I would use Trim(Cells(iRow, iCol).Value) <> "" just to make sure that VBA is looking at the cell's contents.

  • Related