Hello,
Just starting off by saying thanks to Joe4.
In a prior thread I asked a question on how to fill the first empty cell in a range with the word "done". Joe4 gave the following answer which works great:
<code>
Sub CommandButton4_Click()
Dim dfR As Range
Set dfR = Sheets("Sheet1").Range("A13")
If dfR = "" Then
End Sub
</code>
I wanted to expand on this by adding a line that first checks whether range A13:I13 is empty
before filling the row. This must be offset with every loop until row A23:I23. I came up with the
following:
<code><code>
Sub CommandButton4_Click()
Dim dfR As Range
Dim rwRng as Range
Set dfR = Sheets("Sheet1").Range("A13")
</code>
Just starting off by saying thanks to Joe4.
In a prior thread I asked a question on how to fill the first empty cell in a range with the word "done". Joe4 gave the following answer which works great:
<code>
Sub CommandButton4_Click()
Dim dfR As Range
Set dfR = Sheets("Sheet1").Range("A13")
If dfR = "" Then
dfR.Value = "Done"
Else
If dfR.Offset(1, 0) = "" Then
dfR.Offset(1, 0).Value = "Done"
Else
dfR.End(xlDown).Select
If Selection.Row < 23 Then
Selection.Offset(1, 0).Value = "Done"
Else
MsgBox "Range A13:A23 is full!"
End If
End If
End IfEnd Sub
</code>
I wanted to expand on this by adding a line that first checks whether range A13:I13 is empty
before filling the row. This must be offset with every loop until row A23:I23. I came up with the
following:
<code><code>
Sub CommandButton4_Click()
Dim dfR As Range
Dim rwRng as Range
Set dfR = Sheets("Sheet1").Range("A13")
Set rwRng = Sheets("Sheet1").Rows("13:13")
</code>
<code>If rwRng = "" then
</code>
</code>
dfR.Value = "Done"
<code> Else
</code>
</code>
If rwRng.Offset(1, 0) = "" Then
<code> dfR.Offset(1, 0).Value = "Done"
</code>
</code>
<code> Else
</code>
</code>
<code> dfR.End(xlDown).Select
</code>
</code>
<code> If Selection.Row < 23 Then
</code>
</code>
<code> Selection.Offset(1, 0).Value = "Done"
</code>
</code>
<code> Else
</code>
</code>
<code> MsgBox "Range A13:A23 is full!"
</code>
</code>
<code> End If
</code>
</code>
<code> End If
</code>
</code>
<code> End If
End Sub
</code></code>
But it does not give the desired result. Can someone please help me?
Regards
Herman
End Sub
</code></code>
But it does not give the desired result. Can someone please help me?
Regards
Herman