删除命令正在删除数据,而不仅仅是列

我目前正试图重新格式化一些从其他macros接收input的表格。 对表单的input很好,但是一旦我尝试删除需要删除的列(A:H),它只发生在一张纸上,并且所有的数据都在该纸上消失。

这是我的代码:

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 

我也添加了一些屏幕。 第一个显示没有删除发生了什么,第二个是删除。

没有删除

随着删除

要在所有需要的工作表上删除列,我认为你应该写:

 wsSheet.Range("A:H").Delete 

你是否也意味着不应该被删除的列被删除了你的代码?