is there a vba way to search for ### in columns before printing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Excel 2003, windows xp, sp2.

I need a vba way for users to scan sheets before printing for ### in columns
that need to be extended before printing. They are dysfunctional in looking
at print preview and are wasting time and paper.

Thanks as usual for your outstanding help.

Mike
 
turn on the macro recorder

select all cells, then do Find and under options tell it to look at values
and uncheck whole words.


I get code like:

Cells.Select
Range("B1").Activate
Selection.Find(What:="###", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

you can adapt it to do this
Dim r as Range
do
set r = Cells.Find(What:="###", _
After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)
if r is nothing then exit do
r.EntireColumn.Autofit
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top