XLA routines: EE_FormatCols
EE_FormatCols is a handy routine that takes a source range that is formatted, and applies the formatting to a target range
Sub EE_FormatCols(rngSource As range, rngTarget As range) Dim rngTgtHdr As range Dim rngHd As range Dim rngFound As range Dim rngData As range Dim dblDataRows As Double 'http://excelexperts.com/xla-routines-eeFormatCols for updates on this sub routine Set rngData = Intersect(rngTarget.CurrentRegion, rngTarget.CurrentRegion.Offset(1)) Set rngTgtHdr = rngTarget.Rows(1) dblDataRows = rngData.Rows.Count For Each rngHd In rngSource.Rows Set rngFound = rngTgtHdr.Find(what:=rngHd.Cells(1).value, LookIn:=xlValues, lookat:=xlWhole) If Not rngFound Is Nothing Then rngHd.Cells(1).Copy rngFound.PasteSpecial xlPasteFormats rngHd.Cells(, 2).Copy rngFound.Offset(1).Resize(dblDataRows).PasteSpecial xlPasteFormats Application.CutCopyMode = False Set rngFound = Nothing End If Next rngHd Set rngTgtHdr = Nothing Set rngHd = Nothing Set rngFound = Nothing Set rngData = Nothing End Sub
»
- Nick's blog
- Login or register to post comments
- 4453 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago