Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Just out of curiousity, why didn't this work (a changeperpetuated to all sheets)?

Hi

You are missing a single dot before cells.select to set the reference
to ws, ie it should read:

..Cells.Select

I would also skip the select statement as it slows down your code.

Sub Change_for_ALL_Worksheets()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
With ws
'-----------------------------------------------------------------------
'.With Statement code STARTS here below:
With .Cells
.VerticalAlignment = xlCenter
End With
'.With Statement code ENDS here above.
'-----------------------------------------------------------------------
End With
Next ws
End Sub

Hopes this helps
.....
Per


On 20 Aug., 06:20, StargateFan
wrote:
I found the following script, with my line of coding in the middle. *I
was just trying to make all the sheets have horizontal alignment in
them. *After running this, the sheets remained with the alignment they
had. *I'm just curious as to how you'd script something that would run
through all the sheets.

I'm hoping/guessing that this could be a permanent, re-usable script
in our Personal.xls. *Once we find code that works on one sheet,
hopefully we could plug it into the middle, below, and the action
would be repeated on all sheets (?).

I searched and searched and this is about the only script that came
up that _seemed_ to be a good base to have to re-do, as needed.

Anyway, thanks!

Sub Change_for_ALL_Worksheets()
* * Dim ws As Worksheet

* * For Each ws In Worksheets
* * * * With ws
'-----------------------------------------------------------------------
* * * * * * *'.With Statement code STARTS here below:
* * * * * * *Cells.Select
* * * * * * *With Selection
* * * * * * * * *.VerticalAlignment = xlCenter
* * * * * * *End With
* * * * * * *'.With Statement code ENDS here above.
'-----------------------------------------------------------------------
* * * * End With
* * Next ws
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Just out of curiousity, why didn't this work (a change perpetuated to all sheets)?

I found the following script, with my line of coding in the middle. I
was just trying to make all the sheets have horizontal alignment in
them. After running this, the sheets remained with the alignment they
had. I'm just curious as to how you'd script something that would run
through all the sheets.

I'm hoping/guessing that this could be a permanent, re-usable script
in our Personal.xls. Once we find code that works on one sheet,
hopefully we could plug it into the middle, below, and the action
would be repeated on all sheets (?).

I searched and searched and this is about the only script that came
up that _seemed_ to be a good base to have to re-do, as needed.

Anyway, thanks!




Sub Change_for_ALL_Worksheets()
Dim ws As Worksheet

For Each ws In Worksheets
With ws
'-----------------------------------------------------------------------
'.With Statement code STARTS here below:
Cells.Select
With Selection
.VerticalAlignment = xlCenter
End With
'.With Statement code ENDS here above.
'-----------------------------------------------------------------------
End With
Next ws
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
work sheets James Excel Discussion (Misc queries) 2 January 8th 09 04:55 PM
Work Sheets ceejay Excel Discussion (Misc queries) 1 December 7th 07 11:18 AM
change code to work over multiple sheets cda_cmd Excel Programming 2 February 15th 06 01:05 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
I wish to save my Excell work in my work sheets CLC 37 Qld Excel Worksheet Functions 0 May 24th 05 10:56 AM


All times are GMT +1. The time now is 01:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"