columnNo列の行を反復処理する場合は、その変数を宣言して各ループの値を増やす必要があります。あなたのAS
列がTRUE
かFALSE
されている場合は、テスト:
Sub doUntil()
'Do until the cells value is True.
Dim columnNo As Integer, rowno as integer
Calculate
'Refreshing the database.
'this is the column "AS" that has True/False values
columnNo = 45
'This is your starting row
rowno=2
'The True or False Cells are in the AS column
'Starting at row number rowNo loop until we find "True" in column 45/AS
Do Until Cells(rowno, columnNo).value = "True"
'Paint the cell
Cells(rowno, columnno).Interior.Color = RGB(253, 0, 0)
'increment your rowNo to the next row
rowNo = rowNo + 1
Loop
End Sub
ここに大きな変化は、我々はそれに「真」の欄AS
が値を持つ行を打つまで、2から始まる、あなたのすべての行を反復処理しているということです。行をインクリメントしないと、ループは決して終了せず、それは悪いことです。
別の方法としては、forループでこれを行うことができます:
Sub doUntil()
Dim columnNo as Integer, rowNo as Integer
Calculate
columnNo = 45
For rowNo = 2 to 200 'start and end for the loop
If Cells(rowNo, columnNo).value <> "True" Then
Cells(rowno, columnNo).Interior.Color = RGB(253,0,0)
Else
Exit For
End IF
Next RowNo
End Sub
またはループのためにある範囲のオブジェクトを使用して...
Sub doUntil()
Dim rngColumn as Range, rngCell
Calculate
set rngColumn = Columns(45)
For each rngCell in rngColumn.Cells
If rngCell.value <> "True" Then
rngCell.Interior.Color = RGB(253,0,0)
Else
Exit For
End IF
Next RowNo
End Sub
あなたは 'columnNo'変数をどんな形でも増やしていません... – Chrismas007
これはプログラミングではない方法では条件付き書式を使うべきです質問。 – Chrismas007
それは1つの列にあります。 –