View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default Setting column width if #### appears in column

Tom,

I didn't realize you could do that - very cool. I was trying to think of a
solution to cover down to if 0 #'s are displayed. This is what I came up
with, but I'm guessing I missed something:

For Each cell In Range("A2:Z2")
If (Len(cell.Text) = 0 And cell.Value < "") Or InStr(1, cell.Text, "#",
vbTextCompare) Then
cell.EntireColumn.AutoFit
End If
Next

What do you think?

Doug


"Tom Ogilvy" wrote in message
...
for each cell in Range("A2:Z2")
if instr(1,cell.Text,"###",vbTextCompare) then
cell.EntireColumn.Autofit
end if
Next

--
Regards,
Tom Ogilvy



"qwerty" wrote in message
...
If a column is not wide enough for the displayed number, it shows #
signs.
In VBA is there a way to detect which cells in which columns have that
###
so I can use column autofit to set to the width needed?