PDA

View Full Version : action across all open workbooks



lior03
11-07-2007, 02:59 AM
hello
i want to makse sure i am usind the same font (name,size,bold) across all open workbook at a time .i want to make sure all data will be in that format,even if i previouslly used a different font.

Sub fontdefaultgeneral()
Dim ws As Worksheet
Dim wb As Workbook
For Each wb In Application.Workbooks
For Each ws In wb.Worksheets
If ws.Visible = xlSheetVisible Then
With ws.Cells
.Font.FontStyle = "arial"
.Font.Size = 10
.Font.Bold = True
End With
End If
Next
Next
End Sub


how can i force excel togo through each workbook and each sheet to achieve this?.
thanks

unmarkedhelicopter
11-07-2007, 05:09 AM
Qualify your termsSub fontdefaultgeneral()
Dim ws As Worksheet
Dim wb As Workbook
For Each wb In Application.Workbooks
For Each ws In wb.Worksheets
If wb.ws.Visible = xlSheetVisible Then
With wb.ws.Cells
.Font.FontStyle = "arial"
.Font.Size = 10
.Font.Bold = True
End With
End If
Next ws
Next wb
End Sub

Bob Phillips
11-07-2007, 05:55 AM
That is not necessary, ws is already qualified by the For ... Next iteration.

lior03, what is the problem with your code?

Norie
11-07-2007, 07:37 AM
lior

As xld has asked, what's the problem?

That code looks fine to me.

Everything appears fully qualified and it runs no problem for me.

unmarkedhelicopter

That code won't even compile.:)

unmarkedhelicopter
11-07-2007, 09:19 AM
Ooops ! :whistle: