1

簡単な例として、空のセルに到達するまで、列の 22 番目のセルをすべて選択する必要があります。これらのセルをすべてクリップボードにコピーして、別のスプレッドシートに貼り付けることができる必要があります。各セルを適切に選択できますが、すべてが収集された後にコピーされるオブジェクトにそれらを収集する方法がわかりません。

見つめられたコメントにはコードが必要です。

サブ SelectAllValidCells()

  ' select first cell

  [J15].Select

  ' Test contents of active cell; if active cell is empty, exit loop.

  Do Until IsEmpty(ActiveCell)

     ' ***** need to figure out how to gather the valid cells 
     ' here to later copy to clipboard when we reach empty cell 

     ' Step down 22 rows to the next cell.
     ActiveCell.Offset(22, 0).Select

    ' Return to top of loop.
  Loop
  '***** copy gathered cells to clipboard

サブ終了

4

1 に答える 1

1
Sub Tester()

Dim rng As Range, c As Range

    Set c = Range("J15")

    Do
        If rng Is Nothing Then
            Set rng = c
        Else
            Set rng = Application.Union(rng, c)
        End If

        Set c = c.Offset(22, 0)
    Loop While Len(c.Value) > 0


    If Not rng Is Nothing Then
        rng.Copy Range("K1")
    End If

End Sub
于 2012-11-20T23:53:28.053 に答える