我试图解决这个代码的问题,我不能运行多个条件:VBA - 每个细胞
'========================================================================
' CHECKS IF MARKET SECTOR IS EMPTY (FOR LEDGER)
'========================================================================
Private Sub Fill_MarketSector()
Dim LastRow As Long
Dim rng As Range, C As Range
With Worksheets("Ready to upload") ' <-- here should be the Sheet's name
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row ' last row in column A
Set rng = .Range("A2:A" & LastRow) ' set the dynamic range to be searched
Set rng2 = .Range("F2:F" & LastRow)
' loop through all cells in column A and column F
For Each C In rng and For Each C in rng2
If rng.C.Value = "Ledger" and rng2.C.value IsEmpty Then
C.Value = "599" ' use offset to put the formula on column "L"
End If
Next C
End With
End Sub
的代码应该检查A列中包含单词“总帐”和F列是空的,那么它应该放在F栏“599”中。它应该总是检查到最后一行。请问你能帮帮我吗?
非常感谢!
重:“\ *。 '应放入F栏“599”'* - F栏或L栏?你的叙述与你的代码中的评论冲突。 – Jeeped
你有什么错误?提供有关您卡在哪里的信息。 – PankajR
你是对的,我在评论和代码之间有差异。它应该将“599”放在F列中。 我收到语法错误,并且这部分代码已被突出显示: 对于每个C In rng和对于每个C in rng2 如果rng.C.Value =“Ledger “和rng2.C.value IsEmpty然后 – Srpic