以下のコードを実行するたびに、まず Import_R シートの最初の列を Organise_R シートの最初の列に貼り付けます。ただし、何らかの理由で、コードを開始するたびに、前の実行が中断された Organise_R の列にコードが貼り付けられます。organise_R シートの最初の列から常に開始するようにコードに指示する必要があります。b を 1 として定義しようとしましたが、明らかに 4 行目と競合しますか? 助けてください!
For a = 1 To 60
If Application.WorksheetFunction.CountA(Excel.Sheets("Import_R").Columns(a)) > 0 Then
Excel.Sheets("Import_R").Columns(a).Copy
b = Excel.Sheets("Organise_R").UsedRange.Columns.Count
Excel.Sheets("Organise_R").Select
If Application.WorksheetFunction.CountA(Excel.Sheets("Organise_R").Columns(b)) > 0 Then b = b + 1
Excel.Sheets("Organise_R").Columns(b).EntireColumn.Select
Excel.ActiveSheet.Paste
Excel.Application.CutCopyMode = False
Selection.TextToColumns Destination:=Cells(1, b), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1)), TrailingMinusNumbers:=True
End If
Next a