ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I get the row number Based on cell value (https://www.excelbanter.com/excel-programming/379493-how-can-i-get-row-number-based-cell-value.html)

kc-mass

How can I get the row number Based on cell value
 
I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



ankur

How can I get the row number Based on cell value
 
Hi Kevin,

Try This...

Please note that the function takes the column Number...

Function FindRow(Column1 As Integer, TextToFind As String)
Dim i as integer
Dim cell As Object
For i = 1 To 65536
RowOfText = 0
If Cells(i, Column1).Value < "" Then
If Cells(i, Column1).Value = TextToFind Then
RowOfText = i
GoTo 8
End If
End If
Next i

8: If RowOfText = 0 Then
FindRow = 0
Else
FindRow = RowOfText
End If

End Function

Regards
Ankur / Kanchan
www.xlmacros.com

Kc-Mass wrote:

I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value of
"Fish" and "Fish" is in B1207. I would just like the Function to give back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C



kc-mass

How can I get the row number Based on cell value
 
Thanks for all the help!

I have it now.

You folks are great!

Kevin C
"Kc-Mass" <connearney_AT_comcast_PERIOD_net wrote in message
. ..
I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value
of
"Fish" and "Fish" is in B1207. I would just like the Function to give
back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C





ilia

How can I get the row number Based on cell value
 
Use Excel.Worksheet's UsedRange.Rows.Count to iterate through all the
rows.

Also, check for empty cells like so:

If Len(.Cells(iRow, iCol).Value) Then
' check to see whether the value is what you're looking for
End If

"""Kc-Mass ΠΙΣΑΜ(Α):
"""
Thanks for all the help!

I have it now.

You folks are great!

Kevin C
"Kc-Mass" <connearney_AT_comcast_PERIOD_net wrote in message
. ..
I am good with access new with Excel

What I want to do, in VBA, is search Column B and get the row number
for the first occurence of a value. Let's say I am searching for a value
of
"Fish" and "Fish" is in B1207. I would just like the Function to give
back
the row number 1207.

Something Like:

Function FindRow ( Column, TextToFind)

Code
Code
Findrow = X
End Function

A. Is it possible.

B. Could you give me an idea of what I am looking for and where I
should look.

Thx

Kevin C





All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com