Good morning!
I have working code behind a UserForm to update the SubLotCode on a worksheet (called DataCenter). What I need to happen after the SubLotCode is successfully updated is to take that updated information and do a search and replace of all matching instances of the pre-updated SubLotCode on the main sheet (called Calendar). The search and replace will take place in a named range (called SubLotColumn).
Here's my fabulous code:
I have working code behind a UserForm to update the SubLotCode on a worksheet (called DataCenter). What I need to happen after the SubLotCode is successfully updated is to take that updated information and do a search and replace of all matching instances of the pre-updated SubLotCode on the main sheet (called Calendar). The search and replace will take place in a named range (called SubLotColumn).
Here's my fabulous code:
VBA Code:
Private Sub cmdUpdateSub_Click()
Dim SubName_id As String
SubName = Trim(SubName.Text)
lastrow = Worksheets("DataCenter").Cells(Rows.Count, 5).End(xlUp).Row
For i = 1 To lastrow
If Worksheets("DataCenter").Cells(i, 5).Value = SubName Then
Worksheets("DataCenter").Cells(i, 2).Value = SubCode.Text
Worksheets("DataCenter").Cells(i, 4).Value = SubInitials.Text
Worksheets("DataCenter").Cells(i, 7).Value = FieldManager.Text
End If
Next
With Me
.SubName.Clear
.SubCode.Value = ""
.SubInitials.Value = ""
.FieldManager.Clear
End With
MsgBox ("Subdivision Successfully Updated!")
Call UserForm_Initialize
End Sub