Can the formula in vba be considered empty?

Asked 2 years ago, Updated 2 years ago, 91 views

Does anyone know how to determine that cells (2,2) and cells (2,3) refer to empty characters?

Substate()
    Cells(1,1)=3: Cells(1,2).FormulaR1C1="=RC[-1]+5"
    Cells(2,1)=": Cells(2,2).FormulaR1C1="=RC[-1]+6": Cells(2,3).FormulaR1C1="=RC[-1]+7"
'3,8
'"",6,13
End Sub

Search engine google searched for "vba" reference cell empty"
There is no match for vvba 参照 reference cell empty.

vba

2022-09-30 21:28

1 Answers

You can use ISBLANK to determine if the cell is blank in the worksheet function.

If the reference is blank and you don't want to treat it as a number, use IF in conjunction with

Cells(2,2).FormulaR1C1="=IF(ISBLANK(RC[-1]), """, RC[-1]+6)"

You can branch as shown in .

Also, if you want to determine if the cell range is ISBLANK, you can easily use the COUNTA function to return the number of non-empty cells, such as COUNTA(RC[-2]:RC[-1])=0 because COUNTA is a variable length argument.


2022-09-30 21:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.