+ Reply to Thread
Results 1 to 9 of 9

Using VBA to duplicate *everything* about a set of cells in Excel 2010

  1. #1
    Registered User
    Join Date
    02-24-2017
    Location
    RaleigH, NC
    MS-Off Ver
    2010
    Posts
    3

    Using VBA to duplicate *everything* about a set of cells in Excel 2010

    I have a spreadsheet that has a column of cells per week. Each of the cells have borders, formulas, conditional formatting, etc.

    I would like to use VBA to be able to duplicate the original set of cells in the original column as many times as desired. For example, if the spreadsheet starts out with the first column cells set up for Week 1, and I want 10 weeks of columns, how do I have Excel duplicate the formulas, borders, conditional formatting, etc., nine more times to the right of the original column?

    Thanks in advance for your input.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Using VBA to duplicate *everything* about a set of cells in Excel 2010

    Possibly...
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-24-2017
    Location
    RaleigH, NC
    MS-Off Ver
    2010
    Posts
    3
    Quote Originally Posted by dangelor View Post
    Possibly...
    Please Login or Register  to view this content.
    Excellent start. Now what would the VBA code look like that would allow the user to input the number of weeks to duplicate in cell A1, and automaatically duplicate the original column by the number in A1?

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Using VBA to duplicate *everything* about a set of cells in Excel 2010

    Upload a workbook, showing the exact data structure that you are working with. Show the expected output that you are wanting. Data don't have be real data just so the data structure is exactly what you are working with.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Using VBA to duplicate *everything* about a set of cells in Excel 2010

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Using VBA to duplicate *everything* about a set of cells in Excel 2010

    Consider the following code to add to your project. When the workbook opens, an initial cell address will be stored in the ControlTextTip of a textbox on an unused form for retrieval. It will then create a copy of the first sheet (worksheet that will be monitored) as a very hidden second worksheet called "Backup" for comparison to determine if changes were made.

    When a new cell is selected, the code pulls the old cell address from the textbox ControlTextTip and compares that cell address from the active sheet against the same cell on the Backup sheet. If they are different, it writes the original and changed cell values as well as the original and changed interior colors to the Results page. The new target cell address will then be written to the Textbox ControlTextTip and stored as the new old cell address when the process repeats for the next selection.

    When the workbook is closed, the Backup sheet is deleted and the workbook is saved. The code is generic with the main sheet as it does not matter what the name is as long as it is the first sheet . Monitoring of additional formatting types can easily be added to the code

    HTH,
    Maud

    ThisWorkbook module:
    Please Login or Register  to view this content.

    Worksheet module:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,469

    Re: Using VBA to duplicate *everything* about a set of cells in Excel 2010

    Maudibe:

    Question please ... I ran your macros and the color or number written to Results Sheet is 16777215

    This is in Col D & E corresponding to :

    .Cells(NextRow, 4) = Worksheets("Backup").Range(addr).Interior.Color 'ORIG COLOR
    .Cells(NextRow, 5) = Range(addr).Interior.Color 'CHANGED COLOR


    Does that number represent the color ? or what ??

    Checking the RGB of 167 77 215 it comes a cross of purple/violet

  8. #8
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Using VBA to duplicate *everything* about a set of cells in Excel 2010

    Hi Logit

    It is not an RGB color value. It is the long value representation of color Index of 2

    Colors_Long Values.png

    The workbook I posted was only intended to offer some ideas that Lewist can incorporate into his/her project
    Last edited by Maudibe; 02-26-2017 at 01:27 AM.

  9. #9
    Registered User
    Join Date
    02-24-2017
    Location
    RaleigH, NC
    MS-Off Ver
    2010
    Posts
    3

    Re: Using VBA to duplicate *everything* about a set of cells in Excel 2010

    Quote Originally Posted by dangelor View Post
    Please Login or Register  to view this content.
    This was the most simple code and perfectly duplicates the columns, all text, borders, colors, formulas and conditional formatting perfectly. Many thanks for everyone's input.

+ 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. [Excel 2010] Removing Duplicate Data, Leaving 1 Per Month
    By CC4581 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-16-2017, 11:09 AM
  2. [SOLVED] Please I need a macro to delete duplicate cells in a several selected cells in Excel?
    By amkoloui in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-15-2014, 02:17 PM
  3. Replies: 0
    Last Post: 08-08-2012, 11:12 AM
  4. [SOLVED] How to find duplicate values from two sets of data in excel 2010
    By ratu4110 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-30-2012, 04:07 PM
  5. Merge duplicate rows in Excel 2010
    By kcemail2001 in forum Excel - New Users/Basics
    Replies: 9
    Last Post: 01-25-2012, 02:52 PM
  6. Combining data in duplicate rows; Excel 2010
    By jpanside in forum Excel General
    Replies: 2
    Last Post: 01-25-2012, 09:28 AM
  7. Replies: 2
    Last Post: 06-10-2011, 10:26 AM

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