Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Variable rows to repeat

I am creating a macro to reformat data pulled into Excel from a csv file.
It contains various data at the beginning of the report, followed by column
headings and data. The column heading row is not a constant because the info
at the beginning of the report is variable. I want only the column headings
and data to appear on subsequent pages. I can search and locate the column
headings and select them. How do I get this row (or cells) that I've
selected into the PrintTitleRow for subsequent pages?
--
mkferrara
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Variable rows to repeat

With ActiveSheet.PageSetup
.PrintTitleRows = "$2:$2"
.PrintTitleColumns = ""
End With


A good approach is to turn on the macro recorder, then set the page setup
and print area settings manually. Then turn it off and look at the code.
Eliminate the lines that will default and that you don't need to set -
otherwise, each line executes as a separate command and can take a lot of
time.


--
Regards,
Tom Ogilvy



"mkferrara" wrote:

I am creating a macro to reformat data pulled into Excel from a csv file.
It contains various data at the beginning of the report, followed by column
headings and data. The column heading row is not a constant because the info
at the beginning of the report is variable. I want only the column headings
and data to appear on subsequent pages. I can search and locate the column
headings and select them. How do I get this row (or cells) that I've
selected into the PrintTitleRow for subsequent pages?
--
mkferrara

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Variable rows to repeat

Your response seems to show Row 2 as printing all the time. This macro would
be run for different files, and each one could have that header row in a
different row.

If I search for the row with the headers and select them, I get:
Cells.Find(What:="count", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range(Selection, Selection.End(xlToRight)).Select

If I use page setup and choose the row with headers, it appears to be
taking row 18 always, and that won't work for some files.
With ActiveSheet.PageSetup
.PrintTitleRows = "$18:$18"
.PrintTitleColumns = ""
End With

While using "rows to repeat", I can't seem to do a search. Is there a way
to combine the .PrintTitleRows= with the searchable selection?
--
mkferrara


"Tom Ogilvy" wrote:

With ActiveSheet.PageSetup
.PrintTitleRows = "$2:$2"
.PrintTitleColumns = ""
End With


A good approach is to turn on the macro recorder, then set the page setup
and print area settings manually. Then turn it off and look at the code.
Eliminate the lines that will default and that you don't need to set -
otherwise, each line executes as a separate command and can take a lot of
time.


--
Regards,
Tom Ogilvy



"mkferrara" wrote:

I am creating a macro to reformat data pulled into Excel from a csv file.
It contains various data at the beginning of the report, followed by column
headings and data. The column heading row is not a constant because the info
at the beginning of the report is variable. I want only the column headings
and data to appear on subsequent pages. I can search and locate the column
headings and select them. How do I get this row (or cells) that I've
selected into the PrintTitleRow for subsequent pages?
--
mkferrara

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Variable rows to repeat

That was a sample. I assumed you would adapt it to your situation.

Dim r as Range
set r = Cells.Find(What:="count", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
With ActiveSheet.PageSetup
.PrintTitleRows = r.Address(1,1)
.PrintTitleColumns = ""
End With

--
Regards,
Tom Ogilvy


"mkferrara" wrote:

Your response seems to show Row 2 as printing all the time. This macro would
be run for different files, and each one could have that header row in a
different row.

If I search for the row with the headers and select them, I get:
Cells.Find(What:="count", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range(Selection, Selection.End(xlToRight)).Select

If I use page setup and choose the row with headers, it appears to be
taking row 18 always, and that won't work for some files.
With ActiveSheet.PageSetup
.PrintTitleRows = "$18:$18"
.PrintTitleColumns = ""
End With

While using "rows to repeat", I can't seem to do a search. Is there a way
to combine the .PrintTitleRows= with the searchable selection?
--
mkferrara


"Tom Ogilvy" wrote:

With ActiveSheet.PageSetup
.PrintTitleRows = "$2:$2"
.PrintTitleColumns = ""
End With


A good approach is to turn on the macro recorder, then set the page setup
and print area settings manually. Then turn it off and look at the code.
Eliminate the lines that will default and that you don't need to set -
otherwise, each line executes as a separate command and can take a lot of
time.


--
Regards,
Tom Ogilvy



"mkferrara" wrote:

I am creating a macro to reformat data pulled into Excel from a csv file.
It contains various data at the beginning of the report, followed by column
headings and data. The column heading row is not a constant because the info
at the beginning of the report is variable. I want only the column headings
and data to appear on subsequent pages. I can search and locate the column
headings and select them. How do I get this row (or cells) that I've
selected into the PrintTitleRow for subsequent pages?
--
mkferrara

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Variable rows to repeat

Thank you! That does the job perfectly. I wouldn't have been able to figure
that one out by myself.
--
mkferrara


"Tom Ogilvy" wrote:

That was a sample. I assumed you would adapt it to your situation.

Dim r as Range
set r = Cells.Find(What:="count", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
With ActiveSheet.PageSetup
.PrintTitleRows = r.Address(1,1)
.PrintTitleColumns = ""
End With

--
Regards,
Tom Ogilvy


"mkferrara" wrote:

Your response seems to show Row 2 as printing all the time. This macro would
be run for different files, and each one could have that header row in a
different row.

If I search for the row with the headers and select them, I get:
Cells.Find(What:="count", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range(Selection, Selection.End(xlToRight)).Select

If I use page setup and choose the row with headers, it appears to be
taking row 18 always, and that won't work for some files.
With ActiveSheet.PageSetup
.PrintTitleRows = "$18:$18"
.PrintTitleColumns = ""
End With

While using "rows to repeat", I can't seem to do a search. Is there a way
to combine the .PrintTitleRows= with the searchable selection?
--
mkferrara


"Tom Ogilvy" wrote:

With ActiveSheet.PageSetup
.PrintTitleRows = "$2:$2"
.PrintTitleColumns = ""
End With


A good approach is to turn on the macro recorder, then set the page setup
and print area settings manually. Then turn it off and look at the code.
Eliminate the lines that will default and that you don't need to set -
otherwise, each line executes as a separate command and can take a lot of
time.


--
Regards,
Tom Ogilvy



"mkferrara" wrote:

I am creating a macro to reformat data pulled into Excel from a csv file.
It contains various data at the beginning of the report, followed by column
headings and data. The column heading row is not a constant because the info
at the beginning of the report is variable. I want only the column headings
and data to appear on subsequent pages. I can search and locate the column
headings and select them. How do I get this row (or cells) that I've
selected into the PrintTitleRow for subsequent pages?
--
mkferrara

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
printing issue - want to repeat two rows and also 5 rows in column cliffykat Excel Discussion (Misc queries) 0 August 29th 07 10:36 PM
Variable row to repeat at top of page when printing. bobbo Excel Programming 0 July 13th 06 08:28 PM
how to repeat rows at the bottom while using the rows repeat at to Rows to repeat at the bottom Setting up and Configuration of Excel 1 August 31st 05 02:06 PM
Title Cut Off if Rows to Repeat & Columns to Repeat are Both Selec unibaby Excel Discussion (Misc queries) 2 August 24th 05 04:29 PM
Unable to select rows in the repeat rows on top option Noppie Excel Discussion (Misc queries) 2 December 28th 04 03:17 PM


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

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

About Us

"It's about Microsoft Excel"