PC Review


Reply
Thread Tools Rate Thread

How can I get the row number Based on cell value

 
 
Kc-Mass
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
 
 
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
ankur
Guest
Posts: n/a
 
      15th Dec 2006
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


 
Reply With Quote
 
Kc-Mass
Guest
Posts: n/a
 
      16th Dec 2006
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
news:_(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Changing cell text color based on cell number W. Wheeler Microsoft Excel Programming 1 23rd Apr 2007 07:24 AM
Re: Changing cell text color based on cell number W. Wheeler Microsoft Excel Programming 0 22nd Apr 2007 11:56 PM
Changing cell text color based on cell number =?Utf-8?B?c2NvdHR5?= Microsoft Excel Programming 9 14th Apr 2007 06:34 AM
formatting cell number based on previous cell number =?Utf-8?B?UGFzcXVpbmk=?= Microsoft Excel Misc 3 20th Jun 2006 06:36 AM
Creating a certain number of entries based on a number in a cell =?Utf-8?B?UFBW?= Microsoft Excel Worksheet Functions 4 16th Jun 2005 10:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:08 PM.