Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Feb 2008
    LOUISVILLE, Kentucky, USA
    Thanked 0 Times in 0 Posts

    finding two fields / compare. (vba/excel)

    please assist

    This spreadsheet just keeps track of who did what and when.

    what I have is two forms.

    The first form the user puts a hold on a job. By inputting the data throught the form.

    In column b I have the job name (ie... wer1111) in column c I have the sdnumber (ie. 123456).

    05/02/08 WER1111 123456 BY JOHN DOE
    05/02/08 WER1111 098765 BY JANE DOE

    The user in form 2 will key in the jobname and the sd number to ensure it is the correct job on the spreadsheet.

    now when the user goes to release a particular job i need the program to look in column b for the jobname and then look in column c for that particular sd number that they are trying to release. so the user when they input their data it will go to the correct line/ job and add their info.

    any assistance helps , i think this might be a loop and I'm not good with loops at all.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: finding two fields / compare. (vba/excel)

    Let's say the user enters the job name in TextBox1 and the sd number in TextBox2. The following code seeks the row in which this combination is found. I have assumed that column C is formatted as text even though it contains numbers:
    Dim r As Long
    Dim m As Long
    Dim blnFound As Boolean
    blnFound = False
    m = Cells(Rows.Count, 1).End(xlUp).Row
    For r = 2 To m
    If Cells(r, 2) = Me.TextBox1 And Cells(r, 3) = Me.TextBox2 Then
    MsgBox "Found in row " & r
    blnFound = True
    Exit For
    End If
    Next r
    If blnFound = False Then
    MsgBox "Not found"
    End If
    If column C contains numbers, change the line
    If Cells(r, 2) = Me.TextBox1 And Cells(r, 3) = Me.TextBox2 Then
    If Cells(r, 2) = Me.TextBox1 And Cells(r, 3) = Val(Me.TextBox2) Then</code>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts