+ Reply to Thread
Results 1 to 11 of 11

Detecting a paste of data that breaks the current color scheme and repairing color scheme

  1. #1
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Detecting a paste of data that breaks the current color scheme and repairing color scheme

    Hi Guys,

    The thing I am wanting to do is much easier to explain with an example, please download the attachment and have a look.

    If you paste in a large chunk of data into the sheet, the document looks a complete mess and it breaks the color scheme, doesn't fix the formulas in N to O nor does it fix the border.
    If you paste say 4 lines of data into the sheet the document gets confused and again doesn't look very good, you'll have a messed up sheet in terms of color, formula and just general appearance.

    A copy of the color scheme, is avaliable in a hidden row 2 and a copy of the formula is avaliable in N and O on row 2 aswell.

    An example of how to apply the formula is in the current macro that runs

    An example of how to apply the color scheme from row 2 would be something like: Range("A2:T2").Copy: Range("A3:T" & LastRow).PasteSpecial xlPasteFormats

    Please see the attachment for a MUCH clearer example

    Thanks in advance
    Attached Files Attached Files
    Last edited by Hyflex; 08-21-2014 at 06:16 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    hi Ryan, nice to see you again here. Hope you and Aaron are doing well.

    Option, please check attachment. The code is residing in "Small Example" sheet
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    Hi Watersev,

    Thanks for your reply, I've found a few problems so far and they are:

    1) When pasting in data it overwrites the formula column that MAY have values in. There is a working version in my copy of the code that only puts the formula in the blank cells.
    2) It doesn't find the true last row but at the same time ignoring certain columns, in my version there is a working copy of the code that gets around this that you might be able to improve (Basically just needs to do it for any column with a formula in row 2)
    3) When pasting in a big chunk of data the last row doesn't have formats. Can easily be fixed by changing the 5 to a 6 Range("a2:t2").Copy: Range("a3:t" & lrow + 6).PasteSpecial xlPasteFormats
    4) The sheet is constantly trying to update its colors, formulas and border even when it doesn't need to, it should only be doing it if a big chunk of data is pasted messing up the color scheme or if the sheet has under 5 rows remaining.
    5) With a large sheet of data the document becomes really laggy whenever you try and add just 1 more line because it's trying to fix the formats for loads of cells that already have the correct color scheme/formatting.

    Cheers for your copy, it looks oddly simple but you're definitely understanding my aim. It's just has a few small bugs.

    Thanks

  4. #4
    Forum Contributor
    Join Date
    12-01-2010
    Location
    Southampton, England
    MS-Off Ver
    Excel 2007
    Posts
    303

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    Quote Originally Posted by watersev View Post
    hi Ryan, nice to see you again here. Hope you and Aaron are doing well.

    Option, please check attachment. The code is residing in "Small Example" sheet
    What Hyflex meant to say was hello Watersev, how comes you don't have the most points on here yet ? :p I am still on here every now and then, but not as active as I used to be
    Last edited by ad9051; 08-21-2014 at 05:49 PM.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    hi there, please check attachment if it does everything you expect
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    Hey Watersev,

    Thanks once again for your reply, it's much appreciated.

    Unfortunately it's still overwriting any cells in the formula columns that may have values in them, values should not be overwritten by the formula.

    I also encountered this problem: http://i.imgur.com/QzoR5AJ.png which happens when you manually add rows by just typing data in.

    Is there an easier way to do the color formatting because all my sheets are different, I don't mind if it re-fixes the entire red box section as you can see: http://i.imgur.com/gG5O2EB.png and http://i.imgur.com/Cic92CW.png as it's not doing too much format fixing but it means the entire sheet range (A2:T2) can be done in 1 go rather than in batches.

    Cheers once again, you're a very impressive coder :P

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    do you mean the formula should go in the blanks n:o only?

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    please check attachment, "Small Example" sheet code
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    Hey Watersev,

    It works nearly perfectly, however I have found one error that's a bit of a problem, if we're on the last row before we get 5 new rows and we put data in any other column than A it goes wrong and gets confused. (Adds the far right black border but nothing else)

    See: http://i.imgur.com/2hffEwR.png for an example or just download the version you gave me and click in b2 and press x and then enter and you'll spot the error on the far right.

    Cheers for your wonderful help as per usual.

    EDIT: I also find: "Target.Cells(1).Select" or "Application.GoTo Target.Cells(1), 0" better than using "Application.GoTo Target.Cells(1), 1" at the end of the macro.
    Last edited by Hyflex; 08-26-2014 at 03:49 AM.

  10. #10
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    please check attachment
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    Watersev,

    You are a genius. It works perfectly!
    There are a fair few very useful bits of code that I wasn't aware how to use but from your code I can now actually understand them.

    Thank you ever so much!

  12. #12
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    Hey Watersev,

    I just found another little bug that is a bit of a nuisance, I wonder if you could fix this one for me too.

    If I paste a chunk of data into just one column it becomes a complete mess, checkout this example:

    \1

  13. #13
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Detecting a paste of data that breaks the current color scheme and repairing color sch

    hi Hyflex, please check attachment
    Attached Files Attached Files

+ 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. Color Scheme Help
    By rzacharia21 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2012, 11:59 PM
  2. color scheme for charts
    By Barry Au in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-29-2007, 12:37 PM
  3. [SOLVED] Color Scheme
    By [email protected] in forum Excel General
    Replies: 4
    Last Post: 08-14-2006, 01:45 AM
  4. [SOLVED] Color Scheme Trouble
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2006, 04:50 AM
  5. Color scheme trouble
    By [email protected] in forum Excel General
    Replies: 6
    Last Post: 05-16-2006, 02:45 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