# Thread: Return number of line...(.row) (2000)

1. ## Return number of line...(.row) (2000)

Have var1 filled="4C" and var2 filled="CAMPANIA"
How to return in variable var_number_line the number of line where var1 and var2 are on the same line?
In this case var_number_line =9

2. ## Re: Return number of line...(.row) (2000)

Are you looking for a solution as an Excel formula or VBA code? The latter is quite straightforward:

Sub FindRow()
Dim var1 As Variant, var2 As Variant, r As Range
var1 = "4C"
var2 = "CAMPANIA"
Set r = Foglio6.Range("G2")
Do Until (r = var1 And r.Offset(0, 7) = var2) Or IsEmptyŽ
Set r = r.Offset(1, 0)
Loop
If r = var1 And r.Offset(0, 7) = var2 Then
MsgBox "Required row is " & r.Row
Else
MsgBox "Couldn't find specified combination"
End If
End Sub

3. ## Re: Return number of line...(.row) (2000)

Good code!
Work fine, tks.

#### Posting Permissions

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