Cell Properties Across Multiple Worksheets

rbg0519

New Member
Joined
Mar 3, 2011
Messages
6
I have a quick question concerning cell properties.
I'm using Excel 6.5 under Windows XP sp3

I need to (on the back end) use code to modify cell properties (font, style, size, etc.) across multiple spreadsheets. I've managed to use the code to modify the cells on the first sheet, but am unable to recall how to make the changes a global effect across the workbook, affecting all worksheets. (I tried to set this up using a With/EndWith method, but failed)

Any help would be much appreciated.

Here is the code I currently have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim intRowNumber As Integer
Dim intColNumber As Integer
Dim intSheetNumber As Integer

'fill cells A1:E5 (Sheets 1-3) with Value's of that sheet, and cell location
For intSheetNumber = 1 To 3
For intRowNumber = 1 To 5
For intColNumber = 1 To 5
Sheets(intSheetNumber).Cells(intRowNumber, Chr(intColNumber + 64)).Value = Sheets(intSheetNumber).Name & ":$" & Chr(intColNumber + 64) & "$" & Str(intRowNumber)
Next intColNumber
Next intRowNumber
Next intSheetNumber

Range("A1:E5").Columns.AutoFit
Range("A1:E5").Font.Bold = True
Range("A1:E5").Font.Name = "Times New Roman"
Range("A1:E5").Font.Size = 12
Range("A1:e5").Font.Color = vbRed


End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Maybe like so:
Code:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim intRowNumber As Integer
Dim intColNumber As Integer
Dim intSheetNumber As Integer

'fill cells A1:E5 (Sheets 1-3) with Value's of that sheet, and cell location
For intSheetNumber = 1 To 3
    With Sheets(intSheetNumber)
        For intRowNumber = 1 To 5
            For intColNumber = 1 To 5
                .Cells(intRowNumber, Chr(intColNumber + 64)).Value = .Name & ":$" & Chr(intColNumber + 64) & "$" & Str(intRowNumber)
            Next intColNumber
        Next intRowNumber
        With .Range("A1:E5")
            .Columns.AutoFit
            .Font.Bold = True
            .Font.Name = "Times New Roman"
            .Font.Size = 12
            .Font.Color = vbRed
        End With
    End With
Next intSheetNumber

End Sub
 
Upvote 0
jbeaucaire,

Thanks for your time and response.

That worked all except autofitting the cells. Adding the With/WithEnd applied the font, size, and color but did not autofit.
 
Upvote 0

Forum statistics

Threads
1,224,545
Messages
6,179,432
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top