greeting guys
I try adding this formula "=ROW()-1" to the code in column A in sheet BRANDS , but it clears the column A with header . the idea is when delete specific row should not affect for autonumber . it should re arrange again 1,2,3 . actually i don't want writing this formula manually in column A becuase the autonumbering depends on the textboxes on userform when fill the data in textboxes & comboboxes.
I add this to the code but doesn't work
With Columns("A:A")
.Formula = "=ROW()-1"
.Value = Value
End With
this is the whole code
Private Sub CommandButton3_Click()
Dim lReply As VbMsgBoxResult
Dim ws As Worksheet
Dim strFind As String
Dim FoundCell As Range
strFind = Me.TextBox2.Value
Set ws = ThisWorkbook.Worksheets("BRANDS")
If Len(strFind) = 0 Then
MsgBox "PLEASE WRITE THE CODE", vbExclamation, "Entry Required"
Me.TextBox2.SetFocus
Exit Sub
Else
Set FoundCell = ws.Columns(2).Find(What:=strFind, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
If Not FoundCell Is Nothing Then
lReply = MsgBox("Are you sure you want to delete variation (Code " & FoundCell.Value & ")?", 276, "Confirm")
If lReply = vbNo Then Exit Sub
FoundCell.Value = ""
FoundCell.EntireRow.Delete
With Columns("A:A")
.Formula = "=ROW()-1"
.Value = Value
End With
Else
MsgBox "Could Not find " & strFind & " On " & ws.Name, 48, "Not Found"
End If
End If
strFind = "VO" & strFind
On Error Resume Next
Application.DisplayAlerts = False
Sheets(strFind).Delete
Application.DisplayAlerts = True
On Error GoTo 0
'Close Form
Unload Me
End Sub
to know button's name is DELETE on userform
any help to do that,please?