rmc71291
asked on
Move to the Left 3 Cells but I have no Active Cell
I have the following code and (as you can see) it adds text to a cell in column D in the first blank row it sees. However, I want it to move to the left in that same row and select the A column cell. The problem I have is I don't have an active cell after this runs so I'm not sure how to move it to the left 3 cells. Please help!
Dim IsActive As Boolean
Sub AddNewItem()
Worksheets("Main").Unprotect
If UserForm2.TextBox1.Text = "" Then Exit Sub
With Worksheets("Main")
If Application.CountIf(.Range("D:D"), UserForm2.TextBox1.Text) = 0 Then
.Range("D" & .Rows.Count).End(xlUp)(2).Value = UserForm2.TextBox1.Text
MsgBox ("Item Added - Add details of item starting with description")
Else
MsgBox "That Item Already Exists"
End If
End With
UserForm2.TextBox1.Text = ""
UserForm2.TextBox1.SetFocus
IsActive = False
Unload UserForm2
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. This one did exactly what I needed. The solution before could have likley been modified to work but it selected the cell above the one I needed to be selected.
Open in new window
This will set the focus to that cell in column A.