PC Review


Reply
Thread Tools Rate Thread

count 1st cell and last cell that contain specific word

 
 
crapit
Guest
Posts: n/a
 
      22nd Feb 2008
From a column e.g "A"
How to determine the 1st cell and the last cell that contain a specific
word?

A B C
1
2 grp
3 grp
4
5 grp
6
7 hex
8 hex
9 hex
10 grp
11 grp


 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      22nd Feb 2008
Hi
Assuming Your column A data has a heading

Sub tester()
Dim firstCell As Range, lastCell As Range
With Range("A:A")
Set firstCell = .Find("grp", SearchDirection:=xlNext)
Set lastCell = .Find("grp", SearchDirection:=xlPrevious)
End With
MsgBox "First Cell address is " & firstCell.Address
MsgBox "Last Cell address is " & lastCell.Address
End Sub

The first cell tested is A2 for firstcell and last row of data for
lastcell.
Check the find method Help if you want to specify different start
cells for searching.
regards
Paul

On Feb 22, 2:06*pm, "crapit" <biggerc...@yahoo.com> wrote:
> From a column e.g "A"
> How to determine the 1st cell and the last cell that contain a specific
> word?
>
> * * * *A * * * *B * * * *C
> 1
> 2 * grp
> 3 * grp
> 4
> 5 * grp
> 6
> 7 * hex
> 8 * hex
> 9 * hex
> 10 grp
> 11 grp


 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      22nd Feb 2008
Select column A and run:

Sub find_um()
firstt = False
v = "grp"
For Each r In Selection
If v = r.Value Then
If firstt Then
lastone = r.Address
Else
lastone = r.Address
firstone = r.Address
firstt = True
End If
End If
Next
MsgBox (firstone & Chr(10) & lastone)
End Sub

--
Gary''s Student - gsnu2007d


"crapit" wrote:

> From a column e.g "A"
> How to determine the 1st cell and the last cell that contain a specific
> word?
>
> A B C
> 1
> 2 grp
> 3 grp
> 4
> 5 grp
> 6
> 7 hex
> 8 hex
> 9 hex
> 10 grp
> 11 grp
>
>
>

 
Reply With Quote
 
crapit
Guest
Posts: n/a
 
      22nd Feb 2008
err, possible not to use macro? formula

<(E-Mail Removed)> wrote in message
news:52e57e3c-070f-44ba-9ee2-(E-Mail Removed)...
Hi
Assuming Your column A data has a heading

Sub tester()
Dim firstCell As Range, lastCell As Range
With Range("A:A")
Set firstCell = .Find("grp", SearchDirection:=xlNext)
Set lastCell = .Find("grp", SearchDirection:=xlPrevious)
End With
MsgBox "First Cell address is " & firstCell.Address
MsgBox "Last Cell address is " & lastCell.Address
End Sub

The first cell tested is A2 for firstcell and last row of data for
lastcell.
Check the find method Help if you want to specify different start
cells for searching.
regards
Paul

On Feb 22, 2:06 pm, "crapit" <biggerc...@yahoo.com> wrote:
> From a column e.g "A"
> How to determine the 1st cell and the last cell that contain a specific
> word?
>
> A B C
> 1
> 2 grp
> 3 grp
> 4
> 5 grp
> 6
> 7 hex
> 8 hex
> 9 hex
> 10 grp
> 11 grp



 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      22nd Feb 2008
Array enter
=MIN(IF(A2:A21="a",ROW(A2:A21)))
=Max(IF(A2:A21="a",ROW(A2:A21)))
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"crapit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> From a column e.g "A"
> How to determine the 1st cell and the last cell that contain a specific
> word?
>
> A B C
> 1
> 2 grp
> 3 grp
> 4
> 5 grp
> 6
> 7 hex
> 8 hex
> 9 hex
> 10 grp
> 11 grp
>
>


 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      22nd Feb 2008
Hi
Post the question in

microsoft.public.excel.worksheetfunctions

to avoid disappointment!
Paul

On Feb 22, 2:31*pm, "crapit" <biggerc...@yahoo.com> wrote:
> err, possible not to use macro? formula
>
> <paul.robin...@it-tallaght.ie> wrote in message
>
> news:52e57e3c-070f-44ba-9ee2-(E-Mail Removed)...
> Hi
> Assuming Your column A data has a heading
>
> Sub tester()
> Dim firstCell As Range, lastCell As Range
> *With Range("A:A")
> * *Set firstCell = .Find("grp", SearchDirection:=xlNext)
> * *Set lastCell = .Find("grp", SearchDirection:=xlPrevious)
> End With
> * * MsgBox "First Cell address is " & firstCell.Address
> * * MsgBox "Last Cell address is " & lastCell.Address
> End Sub
>
> The first cell tested is A2 for firstcell and last row of data for
> lastcell.
> Check the find method Help if you want to specify different start
> cells for searching.
> regards
> Paul
>
> On Feb 22, 2:06 pm, "crapit" <biggerc...@yahoo.com> wrote:
>
>
>
> > From a column e.g "A"
> > How to determine the 1st cell and the last cell that contain a specific
> > word?

>
> > A B C
> > 1
> > 2 grp
> > 3 grp
> > 4
> > 5 grp
> > 6
> > 7 hex
> > 8 hex
> > 9 hex
> > 10 grp
> > 11 grp- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
crapit
Guest
Posts: n/a
 
      22nd Feb 2008
do i need to put the array across the same row
"Don Guillett" <(E-Mail Removed)> wrote in message
news:eW7tu%(E-Mail Removed)...
> Array enter
> =MIN(IF(A2:A21="a",ROW(A2:A21)))
> =Max(IF(A2:A21="a",ROW(A2:A21)))
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "crapit" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> From a column e.g "A"
>> How to determine the 1st cell and the last cell that contain a specific
>> word?
>>
>> A B C
>> 1
>> 2 grp
>> 3 grp
>> 4
>> 5 grp
>> 6
>> 7 hex
>> 8 hex
>> 9 hex
>> 10 grp
>> 11 grp
>>
>>

>



 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      22nd Feb 2008
This is an Array formula that could be put anywhere on the worksheet. It
refers to the indicated range.
Instead of entering/editing with just ENTER, hold down the ctrl & shift keys
and touch enter at the same time.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"crapit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> do i need to put the array across the same row
> "Don Guillett" <(E-Mail Removed)> wrote in message
> news:eW7tu%(E-Mail Removed)...
>> Array enter
>> =MIN(IF(A2:A21="a",ROW(A2:A21)))
>> =Max(IF(A2:A21="a",ROW(A2:A21)))
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "crapit" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> From a column e.g "A"
>>> How to determine the 1st cell and the last cell that contain a specific
>>> word?
>>>
>>> A B C
>>> 1
>>> 2 grp
>>> 3 grp
>>> 4
>>> 5 grp
>>> 6
>>> 7 hex
>>> 8 hex
>>> 9 hex
>>> 10 grp
>>> 11 grp
>>>
>>>

>>

>
>


 
Reply With Quote
 
crapit
Guest
Posts: n/a
 
      22nd Feb 2008
If the reference is in another worksheet, can I just change to =MIN(IF("abc
num"(A2:A21)="a",ROW("abc num"(A2:A21))))
"Don Guillett" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This is an Array formula that could be put anywhere on the worksheet. It
> refers to the indicated range.
> Instead of entering/editing with just ENTER, hold down the ctrl & shift
> keys and touch enter at the same time.
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "crapit" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> do i need to put the array across the same row
>> "Don Guillett" <(E-Mail Removed)> wrote in message
>> news:eW7tu%(E-Mail Removed)...
>>> Array enter
>>> =MIN(IF(A2:A21="a",ROW(A2:A21)))
>>> =Max(IF(A2:A21="a",ROW(A2:A21)))
>>> --
>>> Don Guillett
>>> Microsoft MVP Excel
>>> SalesAid Software
>>> (E-Mail Removed)
>>> "crapit" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> From a column e.g "A"
>>>> How to determine the 1st cell and the last cell that contain a specific
>>>> word?
>>>>
>>>> A B C
>>>> 1
>>>> 2 grp
>>>> 3 grp
>>>> 4
>>>> 5 grp
>>>> 6
>>>> 7 hex
>>>> 8 hex
>>>> 9 hex
>>>> 10 grp
>>>> 11 grp
>>>>
>>>>
>>>

>>
>>

>



 
Reply With Quote
 
crapit
Guest
Posts: n/a
 
      22nd Feb 2008
Pls ignore the worksheet Qs. If I need to use the min and max in a range
e.g sum('abc ge'!a3:a33), where a3 is the value in MIN array and a33 in MAX
array,is that possible

"crapit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> If the reference is in another worksheet, can I just change to
> =MIN(IF("abc num"(A2:A21)="a",ROW("abc num"(A2:A21))))
> "Don Guillett" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> This is an Array formula that could be put anywhere on the worksheet. It
>> refers to the indicated range.
>> Instead of entering/editing with just ENTER, hold down the ctrl & shift
>> keys and touch enter at the same time.
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "crapit" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> do i need to put the array across the same row
>>> "Don Guillett" <(E-Mail Removed)> wrote in message
>>> news:eW7tu%(E-Mail Removed)...
>>>> Array enter
>>>> =MIN(IF(A2:A21="a",ROW(A2:A21)))
>>>> =Max(IF(A2:A21="a",ROW(A2:A21)))
>>>> --
>>>> Don Guillett
>>>> Microsoft MVP Excel
>>>> SalesAid Software
>>>> (E-Mail Removed)
>>>> "crapit" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> From a column e.g "A"
>>>>> How to determine the 1st cell and the last cell that contain a
>>>>> specific word?
>>>>>
>>>>> A B C
>>>>> 1
>>>>> 2 grp
>>>>> 3 grp
>>>>> 4
>>>>> 5 grp
>>>>> 6
>>>>> 7 hex
>>>>> 8 hex
>>>>> 9 hex
>>>>> 10 grp
>>>>> 11 grp
>>>>>
>>>>>
>>>>
>>>
>>>

>>

>
>



 
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
count if the cell contains a word found in another cell Go Bucks!!! Microsoft Excel Worksheet Functions 2 28th Jul 2009 02:41 PM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Microsoft Excel Misc 0 29th Jun 2009 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Microsoft Excel Misc 0 26th Jun 2009 06:01 PM
Getting a Count for a specific cell Mike S. Microsoft Access 8 4th Apr 2008 05:44 PM
how do I make a word typed in a cell go to a specific cell in anot =?Utf-8?B?TG1hdGFyYXp6bw==?= Microsoft Excel Misc 3 21st Apr 2005 04:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:09 AM.