【发布时间】:2017-01-26 16:21:16
【问题描述】:
我正在为下面留空的数据创建大量列标题。
表格示例
Col 1 | Col 2 | Col3 | Col 4 |
blank | info | blank| info |
我用来收集这些空白并将它们粘贴到“debug.print”中的代码以显示需要信息的列。最终结果应该是:
缺少的信息是:
Col1
Col3
它比我的例子大很多,请有人帮忙看看我哪里出错了,因为它会在我循环时复制信息。
Do Until iCol = 34
If Cells(iRow, iCol) = "" Then
CellMissInfo = CellMissInfo & CurrTitleCol & ": " & vb_
Debug.Print (CellMissInfo)
End If
iCol = iCol + 1
Loop
编辑: 更多代码帮助
iRow = 3
iCol = 22
lastRow = Application.WorksheetFunction.CountA _
(Range("B2", Range("B" & Rows.Count).End(xlUp)))
Do While iRow <= lastRow
If CurrPipeC <> RGB(242, 220, 219) Then 'Pipeline Color'
Do Until iCol = 34
'HERE is my problem'
If Cells(iRow, iCol) = "" Then
CellMissInfo = CellMissInfo & CurrTitleCol & ": " & vb_
End If
iCol = iCol + 1
Loop
新想法:也许如果我将列创建为一个数组,然后通过 LBound 运行到 Ubound 以将列名添加到一起?
【问题讨论】:
-
不清楚你是如何设置 CurrTitleCol 的,好像没有设置?另外,iRow 和 iCol 是如何初始化的?
-
CurrTitleColl = 单元格(1,iCol)。我循环每一行 iRow。然后使用 iCol 移动到下一列进行检查。