+ Reply to Thread
Results 1 to 6 of 6

Copy Conditional Formatting

Hybrid View

Migas.pt Copy Conditional Formatting 10-09-2014, 11:42 AM
Bob Phillips Re: Copy Conditional... 10-09-2014, 11:57 AM
Migas.pt Re: Copy Conditional... 10-10-2014, 03:55 AM
Migas.pt Re: Copy Conditional... 10-10-2014, 05:49 AM
Migas.pt Re: Copy Conditional... 10-13-2014, 11:35 AM
Migas.pt Re: Copy Conditional... 10-13-2014, 12:41 PM
  1. #1
    Registered User
    Join Date
    10-07-2014
    Location
    Lisbon
    MS-Off Ver
    2010
    Posts
    22

    Copy Conditional Formatting

    Hello,

    I need to copy the conditional formatting of a single cell of a single sheet into a column with data.

    However, the conditional formatting should stop being copied until a certain point.

    -The code should copy the formatting from cell M6 of Sheet1.
    -It should stop copying until the last data in column E of Sheet2.
    -Since I will use it on severall sheets, and because some sheets can be blank, the code should recognize that it does not need to copy if there is no data.

    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Copy Conditional Formatting

    Public Sub CopyCF()
    Dim lastrow As Long
    Dim ws As Worksheet
    
        ActiveSheet.Range("M6").Copy
        
        For Each ws In ThisWorkbook.Worksheets
        
            If Not ws Is ActiveSheet Then
            
                lastrow = ws.Cells(ws.Rows.Count, "E").End(xlUp).Row
                If lastrow > 1 Then ws.Range("E13").Resize(lastrow - 12).PasteSpecial Paste:=xlPasteFormats
            End If
        Next ws
    End Sub

  3. #3
    Registered User
    Join Date
    10-07-2014
    Location
    Lisbon
    MS-Off Ver
    2010
    Posts
    22

    Re: Copy Conditional Formatting

    Thank you Bad Philips!

    Could I ask for some changes?

    Could I write it to go copy from the same sheet every time while it pastes on the several sheets of the workbook?
    The column on which is has to paste is not the same on all sheets, could I select a certain column?

    I will add this code to a code I already have which goes from sheet to sheet doing a bunch of stuff. I would like to have a code "for a sheet" and just change it manually to adapt to each sheet.

  4. #4
    Registered User
    Join Date
    10-07-2014
    Location
    Lisbon
    MS-Off Ver
    2010
    Posts
    22

    Re: Copy Conditional Formatting

    So far I have this and it's almost what I need:

    Sub CF()
    Dim a As Long, RNG As Range
    '
    ' CF Macro
    '
    
    '
        Sheets("YTD Detail - Direct").Select
        Range("M7").Select
        Selection.Copy
        Sheets("YTD Detail - Non-Direct").Select
    On Error Resume Next
    Set RNG = Range("K14:K" & Rows.Count).SpecialCells(xlConstants).Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
    End Sub
    It just skips the blank cells, that's because of the "xlConstants", right?
    What should I modify so it does not skip blank cells but does stop when the rows have no data?

    PS- I have very basic knowledge of coding. I just try stuff and see if it works.

  5. #5
    Registered User
    Join Date
    10-07-2014
    Location
    Lisbon
    MS-Off Ver
    2010
    Posts
    22

    Re: Copy Conditional Formatting

    Can I add something to stop the rows.count when on column A is written "Grand Total"?

  6. #6
    Registered User
    Join Date
    10-07-2014
    Location
    Lisbon
    MS-Off Ver
    2010
    Posts
    22

    Re: Copy Conditional Formatting

    I auto solved my request eheh

    Here is the code if needed in the future:

    Sub CF()
    '
    ' CF Macro
    '
    
    '
        Sheets("YTD Detail - Direct").Select
        Range("M7").Select
        Selection.Copy
        Sheets("YTD Detail - Non-Direct").Select
        Range("K14", Range("K:K").Find("*", , , , 1, 2)).Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy Conditional Formatting
    By paesu57 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2014, 07:32 AM
  2. 1) How to do a conditional copy/ap of a row into a new tab (2) Conditional formatting
    By rajivkohli in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-08-2011, 01:41 PM
  3. Conditional Formatting - Can you copy them?
    By alexschecter in forum Excel General
    Replies: 5
    Last Post: 08-07-2008, 04:24 AM
  4. [SOLVED] ... Can I Copy Conditional Formatting...
    By Dr. Darrell in forum Excel General
    Replies: 1
    Last Post: 12-01-2005, 10:10 AM
  5. copy conditional formatting
    By ajitbmunj in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 09-29-2005, 12:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1