Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I have the macro that searches for text information and then inserts a page break when it finds it. However, if the text ins't in the spread sheet then it crashes, below is my code Cells.Find(What:="CM", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase: = _ True, SearchFormat:=False).Activate ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell Does anyone know what could be put into this to ignore the page break command if the txt isn't found in the sheet?? Regards Gaz -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200511/1 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
dim FoundCell as range
set foundcell = Cells.Find(What:="CM", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, MatchCase:=True, SearchFormat:=False) if founcell is nothing then 'do nothing else if foundcell.row 1 then ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=foundcell end if end if Crowbar wrote: Hi I have the macro that searches for text information and then inserts a page break when it finds it. However, if the text ins't in the spread sheet then it crashes, below is my code Cells.Find(What:="CM", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase: = _ True, SearchFormat:=False).Activate ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell Does anyone know what could be put into this to ignore the page break command if the txt isn't found in the sheet?? Regards Gaz -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200511/1 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 Page Break Adjustments causes a page break each cell | Excel Worksheet Functions | |||
Page break or Fit to Page Macro | Excel Worksheet Functions | |||
Page Break Macro | Excel Programming | |||
Using macro for page break | Excel Discussion (Misc queries) | |||
Page break macro | Excel Worksheet Functions |