I'm trying to update two different sheets, where a value in each sheet matches the value of a textbox. The code below, works fine until I try to incorporate the ws2 stuff highlighted in red. Can someone advise how I need to change the code to accomplish the goal?
Code:
Private Sub cmd_Submit_Click()
Application.ScreenUpdating = False
[COLOR=#ff0000]Dim ws2 As Worksheet[/COLOR]
Dim ws3 As Worksheet
[COLOR=#ff0000]Dim FindRow2 As Range[/COLOR]
Dim FindRow3 As Range
[COLOR=#ff0000]Dim UpdateRow2 As Long[/COLOR]
Dim UpdateRow3 As Long
Dim Msg1 As Variant
Dim Response As VbMsgBoxResult
Dim isok As Boolean
isok = True
[COLOR=#ff0000]Set ws2 = ThisWorkbook.Sheets("Summaries")[/COLOR]
Set ws3 = ThisWorkbook.Sheets("Bios")
[COLOR=#ff0000]With ws2
Set FindRow2 = Range("C:C").Find(What:=Me.txt_ClientID, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
If Not FindRow2 Is Nothing Then
UpdateRow2 = FindRow2.Row
Else
Exit Sub
End If[/COLOR]
[COLOR=#FF0000]End With[/COLOR]
With ws3
Set FindRow3 = Range("E:E").Find(What:=Me.txt_ClientID, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
If Not FindRow3 Is Nothing Then
UpdateRow3 = FindRow3.Row
Else
Exit Sub
End If
End With
Msg1 = MsgBox("Were there any data entry errors found?", vbYesNo, "Data Entry Validation")
If Msg1 = vbYes Then
Me.cobo_Nickname.SetFocus
Else
ws3.Range("B" & UpdateRow3).Value = Now()
ws3.Range("C" & UpdateRow3).Value = (Me.cobo_Status)
ws3.Range("J" & UpdateRow3).Value = (Me.cobo_Nickname)
ws3.Range("K" & UpdateRow3).Value = (Me.cobo_Gender)
ws3.Range("L" & UpdateRow3).Value = CDate(Me.txt_DoB)
ws3.Range("M" & UpdateRow3).Value = (Me.txt_SignupAge)
ws3.Range("O" & UpdateRow3).Value = (Me.txt_Phone)
ws3.Range("P" & UpdateRow3).Value = (Me.txt_Email)
ws3.Range("Q" & UpdateRow3).Value = (Me.txt_Street1)
ws3.Range("R" & UpdateRow3).Value = (Me.txt_Street2)
ws3.Range("S" & UpdateRow3).Value = (Me.txt_City)
ws3.Range("T" & UpdateRow3).Value = (Me.cobo_ST)
ws3.Range("U" & UpdateRow3).Value = (Me.txt_Zip)
ws3.Range("V" & UpdateRow3).Value = (Me.cobo_RefCat)
ws3.Range("W" & UpdateRow3).Value = (Me.txt_RefID)
ws3.Range("X" & UpdateRow3).Value = (Me.cobo_RefNickname)
ws3.Range("Z" & UpdateRow3).Value = (Me.txt_Notes)
[COLOR=#ff0000]ws2.Range("B" & UpdateRow2).Value = (Me.cobo_Status)[/COLOR]
End If
Application.ScreenUpdating = True
End Sub