Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Select not actualy selecting the cell

I need to fix the same problem in alot of workbooks. Its just a mater
of centering the same cell in each workbook. All workbooks are layed
out the same and have one worksheet so I thought it would be pretty
simple.

however, I noticed that the only workbook being acted upon was the
selected workbook even though the print.debug listed each workbook.
for lack of nothing else comming to mnd I added the "For Each ws In
Worksheets" but that was not help.
Any help will be appreciated
Thanks


Public Sub CtrZX1Cell()
'centers the cell to keep printing on one sheet
Dim wb As Workbook
Dim ws As Worksheet

For Each wb In Application.Workbooks

For Each ws In Worksheets
Range("F3").Select
With Selection
.HorizontalAlignment = xlCenter

End With
Next ws

Debug.Print wb.Name

Next wb

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Select not actualy selecting the cell

You need t qualify it with your bound workbook ans worksheet variables

Public Sub CtrZX1Cell()
'centers the cell to keep printing on one sheet
Dim wb As Workbook
Dim ws As Worksheet

For Each wb In Application.Workbooks

For Each ws In wb.Worksheets
ws.Range("F3").HorizontalAlignment = xlCenter Next ws

Debug.Print wb.Name

Next wb

End Sub

--

HTH

Bob

"Robert H" wrote in message
...
I need to fix the same problem in alot of workbooks. Its just a mater
of centering the same cell in each workbook. All workbooks are layed
out the same and have one worksheet so I thought it would be pretty
simple.

however, I noticed that the only workbook being acted upon was the
selected workbook even though the print.debug listed each workbook.
for lack of nothing else comming to mnd I added the "For Each ws In
Worksheets" but that was not help.
Any help will be appreciated
Thanks


Public Sub CtrZX1Cell()
'centers the cell to keep printing on one sheet
Dim wb As Workbook
Dim ws As Worksheet

For Each wb In Application.Workbooks

For Each ws In Worksheets
Range("F3").Select
With Selection
.HorizontalAlignment = xlCenter

End With
Next ws

Debug.Print wb.Name

Next wb

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Select not actualy selecting the cell

Thanks Bob, that workes perfectly. Looks like I was in a rush and
getting sloppy!

On Apr 13, 11:44*am, "Bob Phillips"
wrote:
You need t qualify it with your bound workbook ans worksheet variables

Public Sub CtrZX1Cell()
'centers the cell to keep printing on one sheet
* Dim wb As Workbook
* Dim ws As Worksheet

* For Each wb In Application.Workbooks

* * For Each ws In wb.Worksheets
* * * ws.Range("F3").HorizontalAlignment = xlCenter * *Next ws

* * *Debug.Print wb.Name

* Next wb

End Sub

--

HTH

Bob

"Robert H" wrote in message

...



I need to fix the same problem in alot of workbooks. *Its just a mater
of centering the same cell in each workbook. All workbooks are layed
out the same and have one worksheet so I thought it would be pretty
simple.


however, I noticed that the only workbook being acted upon was the
selected workbook even though the print.debug listed each workbook.
for lack of nothing else comming to mnd I added the "For Each ws In
Worksheets" but that was not help.
Any help will be appreciated
Thanks


Public Sub CtrZX1Cell()
'centers the cell to keep printing on one sheet
*Dim wb As Workbook
*Dim ws As Worksheet


*For Each wb In Application.Workbooks


* *For Each ws In Worksheets
* * *Range("F3").Select
* * * *With Selection
* * * * * *.HorizontalAlignment = xlCenter


* * * *End With
* *Next ws


* * Debug.Print wb.Name


*Next wb


End Sub- Hide quoted text -


- Show quoted text -


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
Select a list in 1 cell by selecting an item from another list in Jonners Excel Discussion (Misc queries) 2 July 10th 09 10:31 PM
select a single cell in excel 07, currently selecting a goup pjrick Excel Discussion (Misc queries) 2 July 8th 09 07:53 PM
select list by selecting a cell Dire straits Excel Worksheet Functions 4 May 2nd 06 06:58 PM
select cell rather selecting entire row ilyaskazi[_99_] Excel Programming 1 November 25th 05 02:48 PM
I have 36 legend entries but only need the ones actualy graphed Simon Charts and Charting in Excel 4 April 27th 05 11:37 PM


All times are GMT +1. The time now is 12:59 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"