特定の列をチェックし、それらの列がすべて空白のときに値を返すコードを書くことを試みました。あなたに役立つ希望
Sub Printing()
Dim CheckCol1 As Integer, CheckCol2 As Integer
Dim rowCount As Integer, rowCount1 As Integer, rowCount2 As Integer, currentRow As Integer
Dim currentRowValue1 As String, currentRowValue2 As String
Dim found As String
found = "No"
CheckCol1 = 1 'column A has a value of 1
CheckCol2 = 2 'column B has a value of 2
rowCount1 = Cells(Rows.Count, CheckCol1).End(xlUp).Row
rowCount2 = Cells(Rows.Count, CheckCol2).End(xlUp).Row
rowCount = Application.Max(rowCount1, rowCount2)
' find the first blank cell on both the columns
For currentRow = 1 To rowCount
currentRowValue1 = Cells(currentRow, CheckCol1).Value
currentRowValue2 = Cells(currentRow, CheckCol2).Value
If (IsEmpty(currentRowValue1) Or currentRowValue1 = "") And (IsEmpty(currentRowValue2) Or currentRowValue2 = "") Then
MsgBox ("No data on Column A and B in row" & currentRow)
found = "Yes"
End If
Next
If found = "No" Then ' This will return rowcount+1 when the columns have values throughout the range
MsgBox ("No data on Column A and B in row" & rowCount + 1)
End If
End Sub
注: - いくつかの変数を追加することで、チェックする列の数を増やすことができます。 Checkcol3、rowcount3、currentrowvalue3を追加して3番目の列を追加して、さらに1つの条件をif節に追加することができます
あなたの作品を共有してください。私たちは示唆/助けることができます。 – Valli
私は持っていません。私は研究中に発見されたコードのアイデアはほとんどありませんが、VB Scriptingの正式なトレーニングはありません。だから私はここで助けを求めている。私のためにあなたにそれをするように求めていない、私は正しい方向に私を向けるように頼んでいます。私の口座にマイナスの価値があると感じる理由は分かりません。 – Gehn47
最初の空白セルを探していますか? MATCH(TRUE、INDEX(C:C = ""、0)、0)。これにより、C列の最初の空白セルの行番号が返されます。 – Valli