ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can anybody help..? (https://www.excelbanter.com/excel-programming/365503-can-anybody-help.html)

Thyagaraj

Can anybody help..?
 
I have some code to format a sheet.

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

Regards
Thyagaraj


Ingolf

Can anybody help..?
 
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
Thyagaraj schrieb:

I have some code to format a sheet.

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

Regards
Thyagaraj



Thyagaraj

Can anybody help..?
 

Ingolf wrote:
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
Thyagaraj schrieb:

I have some code to format a sheet.

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

Regards
Thyagaraj

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


Regards
Thyagaraj


Ingolf

Can anybody help..?
 
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



All times are GMT +1. The time now is 11:48 AM.

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