我想在执行代码时排除第14列。
这是代码段:
For Each xRow In xRg.Rows
xStr = ""
For Each xCell In xRow.Cells
xStr = xStr & xCell.Value & Chr(59)
Next
While Right(xStr, 1) = Chr(59) & xCell.Column <> 14
xStr = Left(xStr, Len(xStr) - 1)
Wend
Next
答案 0 :(得分:0)
我认为您应该像这样... For Loop
中排除第14列...
For Each xCell In xRow.Cells
If xCell.Column <> 14 Then xStr = xStr & xCell.Value & Chr(59)
Next
答案 1 :(得分:-1)
无论您做什么,都应尝试使其变得简单和完整(例如,以某种方式编写代码,以便他人轻松复制和粘贴代码)。下面的代码段显示了如何遍历Range("A1:U100")
并检查每个单元格是否在14.列中。
Sub TestMe()
Dim myCell As Range
For Each myCell In Range("A1:U100")
If myCell.Column <> 14 Then
MsgBox "The column different than 14, do something"
Else
MsgBox "This is the 14. column."
End If
Next myCell
End Sub