View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default unselecting or uncopying or whatever in VBA

"switch back to the sheet and hit escape "

You cannot select "anything" on a sheet unless that sheet is active.
The good news is that you don't have to select the sheet or the columns
to hide/unhide the columns...

shtBDA.Columns("A:B").Hidden = False

Also, it is a little more efficient to just hide or unhide the columns
without checking their status first.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

(I've been to Canby, OR)


"Jon in Canby Or."
wrote in message
I'm reasonably proficient in VB6 and Access VBA but am an Excel neophyte so
hopefully you can help me. Here's the scenario:
I do this to unhide some columns:
shtBDA.Columns("A:B").Select
If Selection.EntireColumn.Hidden = True Then
Selection.EntireColumn.Hidden = False
blRehideColumns = True
End If

then I do a bunch of stuff including this sort of thing:
shtBDA.Rows(lngBDAInd).Insert 'insert a new row
shtBDA.Rows(lngBDA_START_ROW).Copy
shtBDA.Rows(lngBDAInd).PasteSpecial

after all that whole bunch of stuff is done I'd like to re-hide the columns
like this:
shtBDA.Columns("A:B").Select
If blRehideColumns Then
Selection.EntireColumn.Hidden = True
End If

but the .Select fails (I reckon) because the Rows...copy has that row
selected. I believe this becauseIt doesn't fail if I Debug and stop
processing, switch back to the sheet and hit escape to deselect the row and
then continue processing.
How can I get that selection cleared from the Rows...copy statement?
Cheers,
Jon