User form to find value

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
204
Office Version
  1. 2010
Platform
  1. Windows
Hi

i have main user-form 1 which has all the information including list box and when user select the name of the person it will find for duplicate and if user press Yes to duplicate msgbox another user-form 2 will popup requiring password and if user enters the correct password it will popup another user-form 3 which has comment box to be updated against initial duplicate find..

problem is that it only updates comment on 1st line row on sheet 1 (where the data updates) and NOT the actual duplicate it finds using staff ID number in column G in sheet1. it only finds first line which is within User-form1 listbox not the line you have selected in User-form1.

below it is the code which works fine within User-form1 and however it dose not work of what i wants to work when placed in user-form 3

VBA Code:
Private Sub CommandButton1_Click()
Dim p As Variant
    Dim lCol As Variant
    Dim response As Variant
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Jobs_Allocation")
Dim y As Long

Application.EnableCancelKey = xlDisabled

If TextBox1 > False Then
  Unload Me
  lCol = frmSelector.lstSelector.List(x, 3)
Set findvalue = Sheet1.Range("G:G").Find(What:=lCol, LookIn:=xlValues)
    If Not findvalue Is Nothing Then
        adr = findvalue.Address
        Do
           Sheet1.Unprotect Password:="123"
            If findvalue.Offset(0, -1).Value = frmSelector.lstSelector.List(x, 2) Then
                findvalue.Offset(0, 6).Value = Format(Now, "HH:MM:SS")
                findvalue.Offset(0, 7).Value = TextBox1.Value
                y = sh.Range("C" & Application.Rows.Count).End(xlUp).Row
                Exit Do
            End If
            Set findvalue = Sheet1.Range("G:G").FindNext(findvalue)
        Loop While findvalue.Address <> adr
        Set findvalue = Nothing
    End If
End If

If TextBox1.Value > 0 Then
        MsgBox "You must enter the comment", vbCritical, "Error message"
        Exit Sub
    End If

End Sub

please can someone help me resolve

Thank you in advance
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top