ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shorter Code (https://www.excelbanter.com/excel-programming/392869-shorter-code.html)

Sandy

Shorter Code
 
Is there any way I can make the following a bit more code efficient?
Thanks in advance
Sandy

Sheets("Chart Data").Select
ActiveWindow.DisplayHeadings = True

Sheets("Info").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data2").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data3").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data4").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data5").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data6").Select
ActiveWindow.DisplayHeadings = True

Etc Etc



Tom Ogilvy

Shorter Code
 
for each sh in worksheets
sh.Activate
ActiveWindow.DisplayHeadings = True
Next

--
Regards,
Tom Ogilvy


"Sandy" wrote:

Is there any way I can make the following a bit more code efficient?
Thanks in advance
Sandy

Sheets("Chart Data").Select
ActiveWindow.DisplayHeadings = True

Sheets("Info").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data2").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data3").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data4").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data5").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data6").Select
ActiveWindow.DisplayHeadings = True

Etc Etc




Sandy

Shorter Code
 
Works a treat!
Thanks Tom
Sandy

"Tom Ogilvy" wrote in message
...
for each sh in worksheets
sh.Activate
ActiveWindow.DisplayHeadings = True
Next

--
Regards,
Tom Ogilvy


"Sandy" wrote:

Is there any way I can make the following a bit more code efficient?
Thanks in advance
Sandy

Sheets("Chart Data").Select
ActiveWindow.DisplayHeadings = True

Sheets("Info").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data2").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data3").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data4").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data5").Select
ActiveWindow.DisplayHeadings = True

Sheets("Chart Data6").Select
ActiveWindow.DisplayHeadings = True

Etc Etc







All times are GMT +1. The time now is 07:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com