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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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