Can anybody help..?

  • Thread starter Thread starter Thyagaraj
  • Start date Start date
T

Thyagaraj

I have some code to format a sheet.

I dont know how to format all the sheets in a workbook.

Regards
Thyagaraj
 
Hi Thyagaraj,

you could make use of a For Each...Next Loop to format all worksheets
in a workbook one by one.

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
'your code
Next 'ws

Regards,
 
Ingolf said:
Hi Thyagaraj,

you could make use of a For Each...Next Loop to format all worksheets
in a workbook one by one.

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
'your code
Next 'ws

Regards,
Hi Ingolf,
It seems the code is not working . I dont know the reason.


Regards
Thyagaraj
 
Hi Thyagaraj,

I forgot to say that in your code you have to use the "ws" variable to
refer to the worksheet correctely. i.e. the following code will format
cell A1 in bold font on each worksheet of your workbook.

Sub font_bold()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
'refer to the worksheet by using the ws variable in your own code
like this
ws.Range("A1").Font.Bold = True
Next 'ws
End Sub

Regards
Ingolf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top