我正在尝试将单元格字符串转换为范围
Dim closeAfcc As Integer
Dim restCases As Integer
Dim AFCCRange As String
Dim rng As Range
i = 2
closeAfcc = 0
restCases = 0
Do
If Sheet1.Cells(i, 6) = "Closed-AFCC" Then
closeAfcc = closeAfcc + 1
AFCCRange = AFCCRange + "sheet1!K" & i & ","
Else
restCases = restCases + 1
End If
i = i + 1
Loop Until Sheet1.Cells(i, 6) = ""
AFCCRange = Left(AFCCRange, Len(AFCCRange) - 1)
Set rng = Range(AFCCRange)
我得到了Error 1004
我的字符串结果是
AFCCRange= sheet1!K2,sheet1!K3,sheet1!K4,sheet1!K6,sheet1!K7,sheet1!K8,sheet1!K9,sheet1!K10,sheet1!K11,sheet1!K12
由于
答案 0 :(得分:0)
更改此代码:
AFCCRange = AFCCRange + "sheet1!K" & i & ","
阅读:
AFCCRange = AFCCRange & "'sheet1'!$K$" & i & ", "
同样改变:
AFCCRange = Left(AFCCRange, Len(AFCCRange) - 1)
阅读:
AFCCRange = Left(AFCCRange, Len(AFCCRange) - 2)