vb programing match function

  • Thread starter Thread starter Tomo
  • Start date Start date
T

Tomo

SPRING/SUMMER JANUARY Red Tab Guys 005010234 30 2
SPRING/SUMMER DECEMBER Red Tab Guys 005040037 32 4
SPRING/SUMMER DECEMBER Red Tab Guys 005040037 34 6


How to find with visual basic code in witch row and column is data with
match 005040037 and 34,
or in this case 3rd row??

Tnx in advance!
 
Assume your values are stored in range a1 to a3 then try this....

Sub test()
Dim r As Range, c As Range, myRow As Long, myCol As Integer
Set r = Range("A1:A3")

For Each c In r
If InStr(1, c.Value, "005040037 34") > 0 Then
myRow = c.Row
myCol = c.Column
End If
Next c

MsgBox myRow
MsgBox myCol

End Sub
 
Nigel said:
Assume your values are stored in range a1 to a3 then try this....

Sub test()
Dim r As Range, c As Range, myRow As Long, myCol As Integer
Set r = Range("A1:A3")

For Each c In r
If InStr(1, c.Value, "005040037 34") > 0 Then
myRow = c.Row
myCol = c.Column
End If
Next c

MsgBox myRow
MsgBox myCol

End Sub


--

Regards,
Nigel
(e-mail address removed)
assume first few columns are meanless, we have column
model size quantity
005010234 30 2
005040037 32 4
005040037 34 6

find
model size formula
005040037 34 =???

i need to match row number for specific combination, model 005040037 and
size 34, result is 3

to find only one value, eg 005040037 formula would be =match("005040037
";A1:A3;0), but for two values i'm stupid..
 
Nigel said:
Assume your values are stored in range a1 to a3 then try this....

Sub test()
Dim r As Range, c As Range, myRow As Long, myCol As Integer
Set r = Range("A1:A3")

For Each c In r
If InStr(1, c.Value, "005040037 34") > 0 Then
myRow = c.Row
myCol = c.Column
End If
Next c

MsgBox myRow
MsgBox myCol

End Sub


--

Regards,
Nigel
(e-mail address removed)
model size quantity
005010234 30 2
005040037 32 4
005040037 34 6



Sub test()
Dim r As Range, c As Range, myRow As Long, myCol As Integer
Set r = Range("a1:e3")

For Each c In r
If InStr(1, c.Value, "005040037") > 0 Then
myRow = c.Row
myCol = c.Column
End If
Next c

MsgBox myRow
MsgBox myCol

End Sub

that works fine, but i need match for 2 values "005040037" and "34"
 
Sub test()
Dim r As Range, c As Range, myRow As Long, myCol As Integer
Set r = Range("a1:a3")

For Each c In r
If InStr(1, c.Value, "005040037") > 0 And _
InStr(1, c.Offset(0, 1).Value, "34") > 0 Then
myRow = c.Row
myCol = c.Column
End If
Next c

MsgBox myRow
MsgBox myCol

End Sub

--

Regards,
Nigel
(e-mail address removed)
 
Check your other post, too.
SPRING/SUMMER JANUARY Red Tab Guys 005010234 30 2
SPRING/SUMMER DECEMBER Red Tab Guys 005040037 32 4
SPRING/SUMMER DECEMBER Red Tab Guys 005040037 34 6

How to find with visual basic code in witch row and column is data with
match 005040037 and 34,
or in this case 3rd row??

Tnx in advance!
 
yes that's it thnx

Nigel said:
Sub test()
Dim r As Range, c As Range, myRow As Long, myCol As Integer
Set r = Range("a1:a3")

For Each c In r
If InStr(1, c.Value, "005040037") > 0 And _
InStr(1, c.Offset(0, 1).Value, "34") > 0 Then
myRow = c.Row
myCol = c.Column
End If
Next c

MsgBox myRow
MsgBox myCol

End Sub

--

Regards,
Nigel
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top