私はこれに対する答えを徹底的に検索したいと思っています。私は、開始する行のユーザー入力に基づいて、あるワークシートから別のワークシートへデータをコピーしようとしています。たとえば、「9」と入力した場合は、それを表す文字を追加し、別のセルまでデータをコピーし始めます。 Excel VBAはワークシートのデータを別のシートのユーザー入力から別のワークシートにコピーします
Sub Transfer()
Dim shSource As Worksheet
Dim cellValue As Range
Dim formatedCellBegin As Range
Dim formatedCellEnd As Range
Set shSource = ThisWorkbook.Sheets("Sheet1") 'Get info from user input sheet
Set cellValue = shSource.Cells(4, "H") 'User input taken from "H4" on sheet1 received in regards to what row to start transfer
Set formatedCellBegin = "J" & cellValue 'Add J to the that row to get the cell to start at
Set formatedCellEnd = "K" & cellValue 'End at cell K - (whatever they pick)
'Sheet 12 is the sheet with all the invoice info
'Sheet 11 is the sheet to put all the info
Sheets("Sheet12").Range("formatedCellBegin:formatedCellEnd").Copy Destination:=Sheets("Sheet11").Range("B20")
End Sub
が、私はそれを得た
...'、formatedCellBegin '以来:
は、以下の変更されたコードを試してみてください。アドレスは 'J12 'のように解決する必要があります。 'F8'を使用してマクロをステップ実行し、イミディエイトウィンドウ(Ctrl + Gキーを押す)に2つの範囲を設定すると、'?formatedCellBegin.address'と入力して正しく設定されていることを確認します。 – BruceWayne
@ケビン・スミスは、私の答えでコードと説明を参照してください –