Consulting

Results 1 to 2 of 2

Thread: Applying Format To ALL sheets in Workbook

  1. #1

    Applying Format To ALL sheets in Workbook

    Morning all,

    I wish to format all sheets in a workbook using the below code:

    [VBA]Range("E4").Select
    ActiveCell.FormulaR1C1 = "Total Time (Mins)"
    Range("E4").Select
    Selection.Copy
    Range("F4").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "Total Time (Actual)"
    Range("F5").Select
    ActiveCell.FormulaR1C1 = _
    "=IF(OR(RC[-2]=0,RC[-1]=0),"""",TEXT(RC[-1]/60/24,""hh:mm""))"
    Range("F5").Select
    Selection.AutoFill Destination:=Range("F5:F135"), Type:=xlFillDefault
    Range("F5:F135").Select
    ActiveWindow.SmallScroll Down:=-114
    Range("G5").Select
    ActiveCell.FormulaR1C1 = "=IF(OR(RC[-3]=0,RC[-2]=0),"""",RC[-3]/RC[15])"
    Range("G5").Select
    Selection.AutoFill Destination:=Range("G5:G135"), Type:=xlFillDefault
    Range("G5:G135").Select
    ActiveWindow.SmallScroll Down:=-120
    Range("V5").Select
    ActiveCell.FormulaR1C1 = "=IF(OR(RC[-18]=0,RC[-17]=0),"""",RC[-17]/60)"
    Range("V5").Select
    Selection.AutoFill Destination:=Range("V5:V135"), Type:=xlFillDefault
    Range("V5:V135").Select
    ActiveWindow.SmallScroll Down:=-102[/VBA]

    How can I go about doing this?

    Regards,

    Matt

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim i As Long

    For i = 1 To Worksheets.Count

    With Worksheets(i)

    .Range("F4").Value = "Total Time (Mins)"
    .Range("E4").Value = "Total Time (Actual)"
    .Range("F5:F135").FormulaR1C1 = _
    "=IF(OR(RC[-2]=0,RC[-1]=0),"""",TEXT(RC[-1]/60/24,""hh:mm""))"
    .Range("G5:G1355").FormulaR1C1 = _
    "=IF(OR(RC[-3]=0,RC[-2]=0),"""",RC[-3]/RC[15])"
    .Range("V5:V135").FormulaR1C1 = _
    "=IF(OR(RC[-18]=0,RC[-17]=0),"""",RC[-17]/60)"
    End With
    Next i
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •