Actually I'm making a code that will find the first blank cell in column 1 and input "1" if I enter "Hello" in cell B1. But the problem is when I input "hello" all the cell of column 1 gets filled with "1".
Here is the code :
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Set ws = ActiveSheet
If Range("B1").Value = "Hello" Then
For Each cell In ws.Columns(1).Cells
If IsEmpty(cell) = True Then cell.Value = "1": Exit For
Next cell
End If
End Sub
Actually I know the fault of my code. When I input hello in cell B1 The loop invokes. And as the loops find the input it executes infinitely. But I am not unable to make the loop execute only once. Pls help anyone!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…