現在、他のマクロからの入力を受け取っているシートを再フォーマットしようとしています。シートへの入力は問題ありませんが、削除する必要のある列を削除しようとすると(A:H)、それは1枚のシートでのみ発生し、そのシート上のすべてのデータは消えます。ここで削除コマンドは、列だけでなくデータを削除します。
は私のコードです:
Dim wsSheet As Worksheet
Dim current_flt_date, dept_time As Date
Dim dept_station, arrv_station, subfleet_type, route, red_eye As String
Dim current_flt_number As Integer
For Each wsSheet In ThisWorkbook.Worksheets
If Not wsSheet.Name = "Sheet3" Then
wsSheet.Rows(1).Value = Worksheets("Sheet3").Rows(1).Value
lCol = Cells(1, Columns.Count).End(xlToLeft).Column
wsSheet.Cells(1, lCol + 1) = "Qty Loaded"
wsSheet.Rows(1).Font.Bold = True
wsSheet.Rows(1).Font.Underline = True
current_flt_date = wsSheet.Cells(2, 1)
Debug.Print current_flt_date
dept_station = wsSheet.Cells(2, 2)
current_flt_number = wsSheet.Cells(2, 3)
dept_time = wsSheet.Cells(2, 4)
arrv_station = wsSheet.Cells(2, 5)
subfleet_type = wsSheet.Cells(2, 6)
Debug.Print subfleet_type
route = wsSheet.Cells(2, 7)
red_eye = wsSheet.Cells(2, 8)
Range("A:H").Delete
End If
Next wsSheet
私もいくつかの画面を追加しました。最初のものは、削除せずに何が起こるかを示し、2つ目は削除を示しています。
もう1つ質問:次のコードを追加して9行を追加し、タイプの不一致が発生しました。 'code' wsSheet.Rows( "1,10")。Shift:= xlDown、CopyOrgin:= xlFormatFromLeftOrAbove 'code ' 何かご意見は? –