【发布时间】:2016-04-20 13:34:34
【问题描述】:
我正在考虑为多个行和列运行 For 循环,但是我正在跳过一些列。
所以 ATM 我的代码与此类似,但这不起作用。如何在不包括我不需要的列的同时表达这个范围的列。
For irow = DateStart To DateEnd
For icolumn = 32 To 40
For icolumn = 43 To 58
For icolumn = 60 To 61
For icolumn = 63 To 67
提前致谢
Sub Button16_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim Drill As String
Dim postRow As Integer
Dim irow As Integer
Dim icolumn As Integer
Dim DateStart As Integer
Dim DateEnd As Integer
Dim SheetDate As Date
'Start Date and End Date Row from Drill Data entry Sheet
DateStart = Sheet16.Cells(4, 9).Value
DateEnd = Sheet16.Cells(5, 9).Value
postRow = 9 ' posting in Uploadsheet
Sheet1.Select
'Drill1 = Range("C16")
For irow = DateStart To DateEnd
For icolumn = 32 To 40
For icolumn = 43 To 58
For icolumn = 60 To 61
For icolumn = 63 To 67
If Cells(irow, icolumn) > 0.01 Then
Sheets("UploadSheet").Cells(postRow, 1) = "A"
Sheets("UploadSheet").Cells(postRow, 2) = Format(Sheet1.Cells(irow, 2), "yyyymmdd") 'Shift Date
Sheets("UploadSheet").Cells(postRow, 3) = Sheet1.Cells(irow, 4) 'Shift NS/DS
Sheets("UploadSheet").Cells(postRow, 4) = Sheet1.Cells(irow, 3) 'equipment type
Sheets("UploadSheet").Cells(postRow, 5) = Sheet1.Cells(4, icolumn) 'code Type
Sheets("UploadSheet").Cells(postRow, 6) = Sheet1.Cells(irow, icolumn) 'Hours for code type
postRow = postRow + 1
Else
End If
Next
Next
Sheets("UploadSheet").Select
End Sub
【问题讨论】: