我正在使用Excel并填写一个单词模板(之前从未做过)。
首先,我正在搜索特定条目的列,然后创建一个具有行特定值的bulletpoint。这里是代码:ApplyBullet默认不应用于Do-Loop
With wd.Selection
.GoTo what:=wdGoToBookmark, Name:="launches"
'Loop until cycled through all unique finds
Do Until foundCells Is Nothing
.Range.ListFormat.ApplyBulletDefault '<----- this doesn't work
'Find next cell with value
Set foundCells = Sh.Columns(2).FindNext(After:=foundCells)
Name = foundCells.Offset(0, 3).Value & Chr(11)
action = foundCells.Offset(0, 5).Value & Chr(11)
.TypeText (Name & " " & action)
'Test to see if cycled through to first found cell
If foundCells.Address = FirstFound Then Exit Do
Loop
End With
如上所述,我想为我找到的每个细胞创建一个bulletpoint。但如果它在Do循环中,突出显示的行不起作用,但在循环外运行......问题在哪里?
编辑: 输入上述前,我做了不存在的值以下检查:
Set foundCells = Sh.Columns(2).Find(what:=month)
'Test to see if anything was found
If Not foundCells Is Nothing Then
FirstFound = foundCells.Address
Else
GoTo NothingFound
End If
所以不应该是关于不存在的值的任何问题(我希望)
可以在(opt1)之前或之前(opt2)“Do Until foundCells Is Nothing”之后放置一行“msgBox(foundCells Is Nothing)”吗? opt1:如果没有弹出消息框,你的foundCells变量就什么都没有。 opt2:messageBox将显示“true”或“false”。如果它是真的,foundCells是没有,如果错误,那么它应该进入循环,我们会继续找到你的问题...;) – Kathara
@Kathara Thx的答案 - 我想我要覆盖这...看编辑 – dv3
好吧,你是如何定义foundCells的?作为范围?作为细胞? – Kathara