Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default inserting page-breaks

hello,

i have an worksheet with data that is exported from an accounting program.
the spreadsheet has an amount every 4,5,6 or 7 lines in column "F". i would
like to have a macro that searches each cell from 1F to the end of the
worksheet and where this is a number in 'x'F i want a page-break inserted
after 'x'.

thanks for any help you can provide


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default inserting page-breaks

TDR,

Here's one way:

Sub test()

Dim c As Range

With ActiveSheet
For Each c In Intersect(.UsedRange,
..Range("F:F")).SpecialCells(xlCellTypeConstants)
.HPageBreaks.Add befo=c.Offset(1, 1)
Next c
End With


End Sub


--
Hope that helps.

Vergel Adriano


"TDR" wrote:

hello,

i have an worksheet with data that is exported from an accounting program.
the spreadsheet has an amount every 4,5,6 or 7 lines in column "F". i would
like to have a macro that searches each cell from 1F to the end of the
worksheet and where this is a number in 'x'F i want a page-break inserted
after 'x'.

thanks for any help you can provide


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default inserting page-breaks

thank you for such a quick reply!!

i'm getting this error - Object variable or With block variable not set

i've found it in the help file so i'll try to figure it out from here (i
think i'll be coming back for the answer though :))


"Vergel Adriano" wrote:

TDR,

Here's one way:

Sub test()

Dim c As Range

With ActiveSheet
For Each c In Intersect(.UsedRange,
.Range("F:F")).SpecialCells(xlCellTypeConstants)
.HPageBreaks.Add befo=c.Offset(1, 1)
Next c
End With


End Sub


--
Hope that helps.

Vergel Adriano


"TDR" wrote:

hello,

i have an worksheet with data that is exported from an accounting program.
the spreadsheet has an amount every 4,5,6 or 7 lines in column "F". i would
like to have a macro that searches each cell from 1F to the end of the
worksheet and where this is a number in 'x'F i want a page-break inserted
after 'x'.

thanks for any help you can provide


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default inserting page-breaks

Hi,

try it this way:

Sub test()

Dim c As Range
Dim rng As Range

With ActiveSheet
Set rng = Intersect(.UsedRange, .Range("F:F"))
If Not rng Is Nothing Then
For Each c In rng
If c.Value 0 Then
.HPageBreaks.Add befo=c.Offset(1, 1)
End If
Next c
End If
End With


End Sub



--
Hope that helps.

Vergel Adriano


"TDR" wrote:

thank you for such a quick reply!!

i'm getting this error - Object variable or With block variable not set

i've found it in the help file so i'll try to figure it out from here (i
think i'll be coming back for the answer though :))


"Vergel Adriano" wrote:

TDR,

Here's one way:

Sub test()

Dim c As Range

With ActiveSheet
For Each c In Intersect(.UsedRange,
.Range("F:F")).SpecialCells(xlCellTypeConstants)
.HPageBreaks.Add befo=c.Offset(1, 1)
Next c
End With


End Sub


--
Hope that helps.

Vergel Adriano


"TDR" wrote:

hello,

i have an worksheet with data that is exported from an accounting program.
the spreadsheet has an amount every 4,5,6 or 7 lines in column "F". i would
like to have a macro that searches each cell from 1F to the end of the
worksheet and where this is a number in 'x'F i want a page-break inserted
after 'x'.

thanks for any help you can provide


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default inserting page-breaks

Thank you very much!

Take care

"Vergel Adriano" wrote:

Hi,

try it this way:

Sub test()

Dim c As Range
Dim rng As Range

With ActiveSheet
Set rng = Intersect(.UsedRange, .Range("F:F"))
If Not rng Is Nothing Then
For Each c In rng
If c.Value 0 Then
.HPageBreaks.Add befo=c.Offset(1, 1)
End If
Next c
End If
End With


End Sub



--
Hope that helps.

Vergel Adriano


"TDR" wrote:

thank you for such a quick reply!!

i'm getting this error - Object variable or With block variable not set

i've found it in the help file so i'll try to figure it out from here (i
think i'll be coming back for the answer though :))


"Vergel Adriano" wrote:

TDR,

Here's one way:

Sub test()

Dim c As Range

With ActiveSheet
For Each c In Intersect(.UsedRange,
.Range("F:F")).SpecialCells(xlCellTypeConstants)
.HPageBreaks.Add befo=c.Offset(1, 1)
Next c
End With


End Sub


--
Hope that helps.

Vergel Adriano


"TDR" wrote:

hello,

i have an worksheet with data that is exported from an accounting program.
the spreadsheet has an amount every 4,5,6 or 7 lines in column "F". i would
like to have a macro that searches each cell from 1F to the end of the
worksheet and where this is a number in 'x'F i want a page-break inserted
after 'x'.

thanks for any help you can provide




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
Inserting automatic page breaks LStewart Excel Discussion (Misc queries) 3 May 14th 10 11:08 PM
Inserting page breaks Rich Mogy Excel Worksheet Functions 3 April 10th 09 11:26 PM
Inserting Page Breaks blasds78 Excel Discussion (Misc queries) 3 May 22nd 07 03:57 PM
Inserting Page Breaks chrisnelsonusa1 Excel Discussion (Misc queries) 3 December 9th 05 09:34 PM
Inserting Page Breaks chrisnelsonusa1[_2_] Excel Programming 2 December 9th 05 08:44 PM


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