LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Finding row number with .find()

When you do a find you need to specify most of the optional arguments. If you
don't specify then they system will use whatever the last setting set by the
user. Additionally while you have said that the value will always be found,
you are still better off to check to see if it was actually found (as opposed
to generating an error) so something like this...

Dim rngFound As Range
Dim lng As Long

Set rngFound = Columns("A").Find(What:=cp, _
LookAt:=xlWhole, _
LookIn:=xlValues, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox cp & " not found"
Else
lng = rngFound.Row
'Carry On
End If

--
HTH...

Jim Thomlinson


"JLGWhiz" wrote:

I would think that x.Row would work:

Set x = Range("sales" & CD).Find(CP)
'selects the correct range Need to get row number
MsgBox = x.Row

"treasuresflemar" wrote:

CP will always be found in column "A"
There will always be only one occurrence of CP in the range.
It will always be found.
Need to see if the sum of columns "B" through "L" in the row CP is
found in = 0 if so then checkpost = True
All columns B:L are formated as currency

What I need x to do is return the row number

Set x = Range("sales" & CD).Find(CP)

Thanks Carl


Function Checkpost(CP As Date, CD As String)
'CP is the date that is being posted
'CD is the Year being posted which is part
'of the named range
'Checkpost returns True if no posting has been made
'to the posting date

Dim x as Integer
dim y

With Worksheets("sales " & CD)
'sets the sheet the data is on for the year invloved

Set x = Range("sales" & CD).Find(CP)
'selects the correct range Need to get row number

y = Range("b" & x, "l" & x).Subtotal

End With

If y = 0 Then
Checkpost = True
'Nothing posted to that day

Else
Checkpost = False
'A posting to that date has been done
End If
End Function




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find previous number and find next number in column DoubleZ Excel Discussion (Misc queries) 4 March 4th 09 08:51 PM
Finding Minimum but if same number repeats in the range, then find MIK Excel Discussion (Misc queries) 1 January 9th 09 03:13 AM
Finding Number Within Range Then Copying Data Below Number to Cells [email protected] Excel Programming 5 October 16th 06 06:32 PM
finding a number and the number of times it occurs luposlipophobia Excel Discussion (Misc queries) 3 June 22nd 06 03:51 AM
FIND is not "finding" a number in a column which contains the numb fdp Excel Worksheet Functions 5 December 7th 05 10:27 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"