Apply Font, Font Size, and Font Color

L

Legacy 436357

Guest
Hello,

Is there a way to alter this code to post the font, font size, and font color to the destination sheets?
What I mean is to maintain the individual cells from the source sheets.
Thank you very much for your help,
XJ

Code:
<code>Sub AddEventsToSheets()
   Call ClearCells
   Dim ws As Worksheet, sh As Worksheet
   Dim Rng As Range, c As Range, fNd As Range
   Dim NrNg As Range, g As Range, m As String
   For Each ws In Sheets(Array("Holidays", "Events"))
      With ws
         Set Rng = .Range("A3:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
         For Each c In Rng.Cells
            m = Format(c, "MMMM")
            Set NrNg = Sheets(m).Range("A3:N33").SpecialCells(xlCellTypeFormulas, 23)
            For Each g In NrNg
               If g.Value = c.Value Then
                  g.Resize(6).SpecialCells(xlBlanks)(1).Value = c.Offset(, 1)
               End If
            Next g
         Next c
         Set Rng = .Range("H3:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
         For Each c In Rng.Cells
            If Month(c) = 1 Then
               m = "december"
               Set NrNg = Sheets(m).Range("A3:N33").SpecialCells(xlCellTypeFormulas, 23)
               For Each g In NrNg
                  If g.Value = c.Value Then
                     g.Resize(6).SpecialCells(xlBlanks)(1).Value = c.Offset(, 1)
                  End If
               Next g
            End If
         Next c
      End With
   Next ws
End Sub
</code>
 
Last edited by a moderator:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try something like this
Declare another variable
Code:
Dim d as Range
replace (twice):
Code:
g.Resize(6).SpecialCells(xlBlanks)(1).Value = c.Offset(, 1)
with:
Code:
set d = c.Offset(, 1)
With g.Resize(6).SpecialCells(xlBlanks)(1)
   .Value = d
   .Font.Name = d.Font.Name
   .Font.Size = d.Font.Size
   .Font.ColorIndex = d.Font.ColorIndex
End With

Code
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,761
Messages
6,132,560
Members
449,736
Latest member
anthx

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