0

セルの文字列の位置を範囲に変換しようとしています

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

ありがとう

4

1 に答える 1

0

このコードを変更します。

AFCCRange = AFCCRange + "sheet1!K" & i & ","

読むには:

AFCCRange = AFCCRange & "'sheet1'!$K$" & i & ", "

また、次のように変更します。

AFCCRange = Left(AFCCRange, Len(AFCCRange) - 1)

読むには:

AFCCRange = Left(AFCCRange, Len(AFCCRange) - 2)
于 2013-07-24T20:52:52.297 に答える