当A列单元格中的值为负数时,如何将N作为对应于A列单元格的B列单元格中的注释。
例如:
A B
12
-123 Negative
123
-456 Negative
答案 0 :(得分:1)
使用VBA
Sub Demo()
Dim ws As Worksheet
Dim lastRow As Long
Dim cel As range
Set ws = ThisWorkbook.Sheets("Sheet2") 'change Sheet2 to your data sheet
With ws
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row 'get last row with data
For Each cel In range("A1:A" & lastRow) 'loop through Column A
If cel.Value < 0 Then cel.Offset(0, 1) = "Negative" 'check if number is negative
Next cel
End With
End Sub
使用公式
在Cell B1
中输入以下公式,然后根据需要拖放/复制。
=IF(SIGN(A1)=-1,"Negative","")