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: 10
Default Row number for End of Template

Thanks...

"Jake Marx" wrote:

Hi Pele,

In order to match a cell's value exactly, you can specify another argument
to the Find method:

Set rng = Columns(3).Find(What:="total", LookAt:=xlWhole)

To store it as a variable, use a Long:

Dim lEndRow As Long

And assign it to the variable instead of using MsgBox:

If Not rng Is Nothing Then lEndRow = rng.Row

Now for your code:

s = 0
z = Cells(s, 3).Value


This won't work, as cells is 1-based (0 means row zero, which doesn't make
sense).

Do
s = s + 1
Cells(s, 3).Select
z = Cells(s, 3)


There's no need to Select anything here - just use z = Cells(s, 3).Value.

If z = "total" Then


String comparisons are case-sensitive by default. So if your cell value has
"Total" or "TOTAL", this won't return True. To do a case-insensitive match,
you can use StrComp():

If StrComp(z, "total", vbTextCompare) = 0 Then
'/ match
Else
'/ no match
End If

That said, a Find will be much quicker than iterating over the cells in the
column.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

Pele wrote:
Jake,

I tried this solution but it didn't work the way I wanted. I wanted
to find the cell that said exactly "TOTAL" as opposed to "TOTAL
SUPPLY".

I also need to capture the row number as a variable to use in another
line of code (as opposed to it being displayed in a message box). I
am not that good at macro.

By the way, can you tell me why the code I'd written didn't work (see
below).

Pele


<snip



 
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
Automatically use next number on a template Nenagh Excel Discussion (Misc queries) 1 June 11th 09 08:12 AM
Template Wizard - Number of fields Randy Cole Excel Discussion (Misc queries) 0 June 8th 06 09:20 PM
How do i number a template so that it will increase 1,2,3 etc? Dreamworks New Users to Excel 1 July 28th 05 11:43 AM
How do I set up a template to assign a unique number? Feltonblue Excel Programming 3 October 5th 04 06:55 PM
How do I set up an Excel template to generate a new number every . Tom Ogilvy Excel Programming 0 September 15th 04 05:24 PM


All times are GMT +1. The time now is 10:40 PM.

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"