+ Reply to Thread
Results 1 to 8 of 8

Easy way of copying a table into a macro?

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Everett, Washington
    MS-Off Ver
    Excel 2007
    Posts
    28

    Easy way of copying a table into a macro?

    I just spent a few hours coming up with a data table template that I need. It has a very detailed layout, lots of borders of various kinds, merged cells, specific cell height and width, etc. It will be generated automatically and have all the info filled in automatically, so I'm wondering if there is absolutely any easy way to copy this into a Macro? Or do I have to basically go line by line for the whole thing?

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Easy way of copying a table into a macro?

    You could record yourself creating it to produce the general framework, and then tidy up the code in the editor.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: Easy way of copying a table into a macro?

    Hi Tom,

    It sounds like you want to Copy your range and then Paste Special -> Formats Only.

    see http://www.ablebits.com/office-addin...alues-formats/ or
    http://www.bing.com/videos/search?q=...=0&FORM=NVPFVR
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    07-08-2013
    Location
    Everett, Washington
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Easy way of copying a table into a macro?

    Quote Originally Posted by XeRo Solus View Post
    You could record yourself creating it to produce the general framework, and then tidy up the code in the editor.
    Nah, that won't work. Took me a long time to create it the first time and there were lots of errors with the borders. I'd rather just do it in VBA than to redo it by hand and hope the code picks it up.

    Quote Originally Posted by MarvinP View Post
    Hi Tom,

    It sounds like you want to Copy your range and then Paste Special -> Formats Only.

    see http://www.ablebits.com/office-addin...alues-formats/ or
    http://www.bing.com/videos/search?q=...=0&FORM=NVPFVR
    Hmmm... sorry, no, that doesn't look at all like what I want. I need to automate the generation here, so I need to put it into VBA code.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Easy way of copying a table into a macro?

    I think you're out of luck then. The only two ways I know of to generate code are recording or manual entry.

  6. #6
    Registered User
    Join Date
    07-08-2013
    Location
    Everett, Washington
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Easy way of copying a table into a macro?

    Yeah, I think I'll just manually enter the code. Hopefully it won't be too annoying.

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,570

    Re: Easy way of copying a table into a macro?

    You have a template. Therefore the macro should:
    1) fill in the template with the new data/info,
    2) copy it to a new workbook saving it as an xlsx, or
    3) copy it to the end of some existing record workbook, or
    4) copy it to a new sheet within the workbook that contains the macro, and
    5) clear the template for re-use.
    Ben Van Johnson

  8. #8
    Registered User
    Join Date
    07-08-2013
    Location
    Everett, Washington
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Easy way of copying a table into a macro?

    Oh I see what you are saying now. I'd save the empty template as some file name, then my macro would simply copy-paste that template from the file. That's pretty smart. Too bad I'm almost done making it all in VBA.

+ 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. Is there an easy example to create a Pivot Table within a macro
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2006, 01:00 PM
  2. Need Help With Copying Formulas-Easy Question, I Promise
    By petern in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-16-2005, 10:25 PM
  3. Need Help Copying Formulas-Easy Question, I Promise
    By petern in forum Excel General
    Replies: 1
    Last Post: 01-15-2005, 08:06 PM
  4. Need Help Copying Formulas-Easy Question, I Promise
    By petern in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-15-2005, 06:32 AM
  5. Need Help With Copying Formulas-Easy Question, I Promise
    By petern in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-14-2005, 05:57 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