Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'deselecting' cells that have been selected 1

Status
Not open for further replies.

sue1127

Programmer
Jul 10, 2000
88
US
In Excel 2000, I have a vba macro that selects the worksheet, unhides columns that were previously hidden and saves the spreadsheet under a new name. This is the code:

Cells.Select
Selection.EntireColumn.Hidden = False
ThisWorkbook.SaveAs "C:\Invoices\excel_upload.xls"


The problem is that in the new workbook, the spreadsheet is still selected. It seemed to me that there should be a Cells.Deselect command, but that doesn't seem to be the case. Does anyone know how I can deselect the cells after unhiding the columns and before saving the workbook?

Thanks very much.

Sue

 
AFAIK, there's always SOMEthing selected in an Excel spreadsheet. . . the best fix would be to avoid selecting in the first place. Consolidate your two lines of code into:

Cells.EntireColumn.Hidden = False

And if you do run into selection issues for any reason, you can always select a single cell of your choice:

Range("A1").Select



VBAjedi [swords]
 
Thanks,vbajedi. I combined the two lines of code as you suggested, and it worked
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top