View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika Dick Kusleika is offline
external usenet poster
 
Posts: 179
Default VPageBreaks in excel.

Jyoti

Here's an example that tells you where the page breaks are, deletes them and
sets one to the last visible column.

Sub FindVPB()

Dim vpb As VPageBreak
Dim vCount As Long
Dim i As Long
Dim LastVisible As Range
Dim TempRange As Range

Set TempRange = Sheet1.UsedRange(Sheet1.UsedRange.Count).Offset(1, 1)
TempRange.Value = 1

For Each vpb In Sheet1.VPageBreaks
If vpb.Type = xlPageBreakManual Then
MsgBox "Manual vertical break at " & _
vpb.Location.Address
vCount = vCount + 1
End If
Next vpb

If vCount 0 Then
For i = vCount To 1 Step -1
Sheet1.VPageBreaks(i).Delete
Next i
End If

With ActiveWorkbook.Windows(1)
Set LastVisible = _
.VisibleRange.Columns(.VisibleRange.Columns.Count)
End With

Sheet1.VPageBreaks.Add LastVisible
TempRange.ClearContents

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.


"Jyoti" wrote in message
...
Hi,

Using VBA code how can u find out which column the
vertical page break is set to
and how can u change this vertical pagebreak to the last
visible column.

Thanx
Jyoti.