Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Bking
 
Posts: n/a
Default How do I find a cell starting with a specific letter?

I have a large worksheet contains rwos with name and address columns. it is
sorted in ascending order by the last name column and address. I want to
print a list of the names and addresses with page breaks at specific letters.
How can I locate the first row with a last name beginning with a specific
letter so that I can insert a page break? I know I can do this manually by
scrolling throught the list, finding the right row, selecting it and
inserting a page break. However, I would like to create a macro to insert
all the page breaks automatically.
  #2   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Doesn't help with wanting a macro but here's a formula that will do what you
want:

Assume last names are in the range B2:B200

In a cell, say, J1 enter the letter of the last name that you want to find.

Either one of these formulas entered as an array using the key combo of
CTRL,SHIFt,ENTER:

=MIN(IF(LEFT(B2:B200)=J1,ROW(2:200)))

=MATCH(J1,LEFT(B2:B200),0)+1

Biff

"Bking" wrote in message
...
I have a large worksheet contains rwos with name and address columns. it
is
sorted in ascending order by the last name column and address. I want to
print a list of the names and addresses with page breaks at specific
letters.
How can I locate the first row with a last name beginning with a specific
letter so that I can insert a page break? I know I can do this manually
by
scrolling throught the list, finding the right row, selecting it and
inserting a page break. However, I would like to create a macro to insert
all the page breaks automatically.



  #3   Report Post  
Héctor Miguel
 
Posts: n/a
Default

hi, Bking !

... a large worksheet... name and address...sorted in ascending... by the last name... and address
... print a list of the names and addresses with page breaks at specific letters
... locate the first row with a last name beginning with a specific letter so that I can insert a page break?
... I would like to create a macro to insert all the page breaks automatically.


you might want to give a try with the following code
starting at row 3, assuming rows 1 and 2 are title and the first letter... no pagebreak is needed -?-
please note that Like [text-comparison-operator] is case-sensitive, so... play with the specific letters you need.

hth,
hector.

Sub BreakEveryLetter()
Application.ScreenUpdating = False
Dim nRow As Long
With ActiveSheet
On Error Resume Next
For nRow = 1 To .HPageBreaks.Count
.HPageBreaks(1).Delete
Next
On Error GoTo 0
For nRow = 3 To Range("a65536").End(xlUp).Row
If Left(Cells(nRow, 1), 1) Like "[BDF]" _
And Left(Cells(nRow, 1), 1) < Left(Cells(nRow - 1, 1), 1) _
Then .HPageBreaks.Add Rows(nRow)
Next
End With
End Sub


  #4   Report Post  
Bking
 
Posts: n/a
Default

Thanks Biff.

The first formula works. The second formula returned #Value!.

I created a column for the first formula. When I change the value in J1,
the first row in that column with a value 0 is the letter in J1.

Now if I can only figure out how to incorporate one of these nto a macro.


"Biff" wrote:

Hi!

Doesn't help with wanting a macro but here's a formula that will do what you
want:

Assume last names are in the range B2:B200

In a cell, say, J1 enter the letter of the last name that you want to find.

Either one of these formulas entered as an array using the key combo of
CTRL,SHIFt,ENTER:

=MIN(IF(LEFT(B2:B200)=J1,ROW(2:200)))

=MATCH(J1,LEFT(B2:B200),0)+1

Biff

"Bking" wrote in message
...
I have a large worksheet contains rwos with name and address columns. it
is
sorted in ascending order by the last name column and address. I want to
print a list of the names and addresses with page breaks at specific
letters.
How can I locate the first row with a last name beginning with a specific
letter so that I can insert a page break? I know I can do this manually
by
scrolling throught the list, finding the right row, selecting it and
inserting a page break. However, I would like to create a macro to insert
all the page breaks automatically.




  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

That is because it is an array formula, so you commit it with
Ctrl-Shift-Enter, not just Enter.

Actually, to be of any use to you to replicate for other letters, the table
should be absolute. When you do this, you will see the formula surrounded by
{...} in the formula bar. Excel inserts these, you do not need to type them
in.

=MATCH(J1,LEFT($B$2:$B$200),0)+1

--
HTH

Bob Phillips

"Bking" wrote in message
...
Thanks Biff.

The first formula works. The second formula returned #Value!.

I created a column for the first formula. When I change the value in J1,
the first row in that column with a value 0 is the letter in J1.

Now if I can only figure out how to incorporate one of these nto a macro.


"Biff" wrote:

Hi!

Doesn't help with wanting a macro but here's a formula that will do what

you
want:

Assume last names are in the range B2:B200

In a cell, say, J1 enter the letter of the last name that you want to

find.

Either one of these formulas entered as an array using the key combo of
CTRL,SHIFt,ENTER:

=MIN(IF(LEFT(B2:B200)=J1,ROW(2:200)))

=MATCH(J1,LEFT(B2:B200),0)+1

Biff

"Bking" wrote in message
...
I have a large worksheet contains rwos with name and address columns.

it
is
sorted in ascending order by the last name column and address. I want

to
print a list of the names and addresses with page breaks at specific
letters.
How can I locate the first row with a last name beginning with a

specific
letter so that I can insert a page break? I know I can do this

manually
by
scrolling throught the list, finding the right row, selecting it and
inserting a page break. However, I would like to create a macro to

insert
all the page breaks automatically.








  #6   Report Post  
Bking
 
Posts: n/a
Default

Sorry for the delay in responding. I had another project that I needed to
complete. I tried this code, but it looks like nothing happens to the
worksheet. I understand most of what the code is trying to do.

I added several page breaks to theworksheet and ran the code. The page
breaks I added were gone. But none were added. I did change the Range to
b65536 since column b is the column I am keying off of for the page breaks.

One thing I have to do before printing is to filter for non-blanks in col A.
But I ran the code before doing the filter as well as after filtering.
Still no page breaks.

Any ideas what I might be doing wrong?

Thank you.
Bob

"Héctor Miguel" wrote:

hi, Bking !

... a large worksheet... name and address...sorted in ascending... by the last name... and address
... print a list of the names and addresses with page breaks at specific letters
... locate the first row with a last name beginning with a specific letter so that I can insert a page break?
... I would like to create a macro to insert all the page breaks automatically.


you might want to give a try with the following code
starting at row 3, assuming rows 1 and 2 are title and the first letter... no pagebreak is needed -?-
please note that Like [text-comparison-operator] is case-sensitive, so... play with the specific letters you need.

hth,
hector.

Sub BreakEveryLetter()
Application.ScreenUpdating = False
Dim nRow As Long
With ActiveSheet
On Error Resume Next
For nRow = 1 To .HPageBreaks.Count
.HPageBreaks(1).Delete
Next
On Error GoTo 0
For nRow = 3 To Range("a65536").End(xlUp).Row
If Left(Cells(nRow, 1), 1) Like "[BDF]" _
And Left(Cells(nRow, 1), 1) < Left(Cells(nRow - 1, 1), 1) _
Then .HPageBreaks.Add Rows(nRow)
Next
End With
End Sub



Reply
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
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
up to 7 functions? ALex Excel Worksheet Functions 10 April 12th 05 06:42 PM
How do I find the contents of a cell using the "ADDRESS" function. sweeney Excel Worksheet Functions 2 April 5th 05 03:23 AM
Highlight a row if a specific cell is specific numbers/words sea0221 Excel Worksheet Functions 2 March 9th 05 12:06 AM
How do I find a mode while disregarding a specific cell value? glasskit Excel Worksheet Functions 1 January 25th 05 07:47 PM


All times are GMT +1. The time now is 05:11 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"