0
VBAに比較的新しいです。私が実行した状況は、Xをコピーして貼り付ける必要がある私は以下のコードを使って別のシートにコピーするだけでうまくいきました。私が今実行している問題は、私が変更して列Aに数式があるので、それを少し動かすことです。ただし、コードは式をコピーしています。ExcelのVBA自動化行全体をセル値に基づいて "X"回コピーして別のシートに貼り付けます
私はpastespecialに関するもう少し研究をしましたが、以下の最初のコードと同じようにコードを取得して、列Aの式の値を貼り付けることしかできないようです。私は行全体をコピーすることには拘束されていませんが、列A-Yが必要です。どんな援助も大歓迎です!
Public Sub CopyData()
' This routing will copy rows based on the quantity to a new sheet.
Dim rngSinglecell As Range
Dim rngQuantityCells As Range
Dim intCount As Integer
' Set this for the range where the Quantity column exists. This works only if there are no empty cells
Set rngQuantityCells = Range("D1", Range("D1").End(xlDown))
For Each rngSinglecell In rngQuantityCells
' Check if this cell actually contains a number
If IsNumeric(rngSinglecell.Value) Then
' Check if the number is greater than 0
If rngSinglecell.Value > 0 Then
' Copy this row as many times as .value
For intCount = 1 To rngSinglecell.Value
' Copy the row into the next emtpy row in sheet2
Range(rngSinglecell.Address).EntireRow.Copy Destination:= Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
' The above line finds the next empty row.
Next
End If
End If
Next
End Sub
も - 私はしばらくの間、このフォーラムの周りに潜んでいましたし、あなたのすべては、あなたがここに偉大なリソース何をすべきかで素晴らしいです!最終的に参加してうれしいです。
:シート( "HDHelp1")範囲( "A" &Rows.Count).END(xlUp).Offset(1).Resize(rngSinglecell.Value。 、255).Value = _ 範囲(範囲( "A"&rngSinglecell.Row)、範囲( "Y"およびrngSinglecell.Row))値 – DChantal
@DChantal - 残念ながら最後の 'And'は'& ' 。私は答えを編集しました。 –
これは完全にあなたに感謝しました!私は "rngSingelCell"を編集するように思えますが、これは人の将来の使用のために "Single"を修正するためです(6文字以下)。 – DChantal