format cells that have been copied

  • Is it possible to have excel format a range if it has been copied to clipboard?


    I have a page with several ranges that I would like to copy from excel to other software. As there may be several ranges (14 rows each seperated by a blank row) to copy, it may become difficult to keep track of the data I have copied. I would like to be able to apply formatting, (change cell colour) once a range has been copied to keep track of where I am upto.


    I have been able to use the BEFORE RIGHT CLICK code in VB to cover te right click copy method but is there a better way that will also cover the EDIT>COPY and CTRL+C copy methods?

  • Re: format cells that have been copied


    I've never done something like what you are describing, but I think reading this should help you: http://www.cpearson.com/excel/Clipboard.aspx


    Using the data object to interface with the clipboard would allow you to check if a selected range matches data in your clipboard. You might also consider using the SelectionChange event because it would trigger when you selected ranges rather than just when you right click.


    Good Luck!

  • Re: format cells that have been copied


    This works for CTRL + C:


    In ThisWorkbook module


    Code
    Private Sub Workbook_Open()
    
    
    Application.OnKey "^{C}", "test"
    Application.OnKey "^{c}", "test"
    
    
    End Sub


    and in a code module


    Code
    Sub test()
             
    Selection.Font.ColorIndex = 7
         
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!