如何正确地转义VBA / excel中的范围

时间:2018-04-12 18:36:01

标签: excel excel-vba vba

我接下来是这段代码。我正在努力解决这个问题并正确地尝试连接范围并正确地避开(双倍双引号?)范围。

Worksheets(ws_name).Range("B" & (row + 1)).Formula = "=COUNTIF(""B2:B"" & row, "">0"")"

我搜索过并搜索过但找不到我的问题!

Dim ws_name
Dim row As Long
For Each ws_name In Worksheet_array
    If (ws_name <> "") Then
        Debug.Print ws_name
        row = Worksheets(ws_name).Range("B" & rows.count).End(xlUp).row
        Worksheets(ws_name).Range("B" & (row + 1)).Formula = "=COUNTIF(""B2:B"" & row, "">0"")"
    End If
Next ws_name

1 个答案:

答案 0 :(得分:3)

尝试,

Worksheets(ws_name).Range("B" & (row + 1)).Formula = "=COUNTIF(B2:B" & row & ", "">0"")"