+ Reply to Thread
Results 1 to 16 of 16

Creating new table with macro

  1. #1
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Creating new table with macro

    Hello

    i need to create a macro that will make new day table.
    for example:

    i have a table for day 1 and when i press on a button it will make a new table for day 2 below it and so on.
    however if the table contain a data it will not copy the data and create only clean table.

    Thanks for your help!
    Last edited by damaple; 11-01-2013 at 09:38 AM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Creating new table with macro

    Hi

    What do you mean using the word "table"? If your data are in a real table, this expanding itself as you add data in it.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    Thanks for answering.

    i'll explain myself again.

    i have table with data in it. i want to create a button or macro or whatever that when i press it, it will create a new clean table without the data similar in the style to the table b4 and so on.
    i made this code which copy the cells to other location.
    Please Login or Register  to view this content.
    but there's 2 problem with it:
    1. it only copy 1 time to one location and i want that the the range cell it will copy will change every time new table is created.
    2. if there's data in the table it will copy the the table with the data.

    edit:
    ok i added that it clears the data, you can see the example in the attached file.
    now how do i make it change the destination of the range when you click the button, and make new button below it with the same option.
    Attached Files Attached Files
    Last edited by damaple; 10-31-2013 at 05:50 AM.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Creating new table with macro

    I am sure that VBA experts that are online, have a better sugestion but until then here is a suggestion.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    Thanks for your help it works but may i ask how to do this and keep the style in those cells?

    and how did you do this on normal xls file and not xlsm file? because only in this file format it let me do function and macros.

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Creating new table with macro

    Not sure whay you mean by this "how to do this and keep the style in those cells?"

    In Excel editions before 2007 the file was saved as xls and when a macro was in that workbook, a notification was appeared when you tried to open that workbook.

  7. #7
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    i mean that if you put a background-color in the "name" cell for example it wont copy the color of it to the next created table.

    and im using excel2010, and when im not saving the file as xlsm a window with the macro alert thing pops and wont let me use the function.

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Creating new table with macro

    Ok. Use this.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    it works for all the cells in the table except the first row (with the name, date...)

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Creating new table with macro

    Run this one.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    Thanks, but theres 2 problem i found:
    1. the style of the 2 row of each table doesnt styled
    2. if you press the button when the table doesnt contain a data or with a data the next created table will be on the cells. try it urself.

    and a question: is it posible to move the create table button each time you press it in several rows if you program it?

    thanks

  12. #12
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    sorry for the double posts... up

  13. #13
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Creating new table with macro

    Upload a worksheet showing what you mean.

  14. #14
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    here, i press the button several times to show the created tables creating over the table before.
    somehow it need to take 5 rows down
    Attached Files Attached Files

  15. #15
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Creating new table with macro

    The code count and find which is the last row in column B which has data, then skip a row and create a new table to the next empty area. So needs the last row in column B of the last table to have data in it.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    10-29-2013
    Location
    israel
    MS-Off Ver
    Microsoft Office 2013
    Posts
    58

    Re: Creating new table with macro

    ok now there are still 2 problems..
    doesnt copy the style of the cells.
    and in row 2 of the table it doesnt copy the border.

    and how can i change the button position every time i click on it?
    if the button is below the table, after clicking on it and creating new table i want the button to be below the new table.

    nvm, i manage to do it myself

    Please Login or Register  to view this content.
    with the button changing his position after every click.

    Thanks anyways and big thank you for your help!
    Last edited by damaple; 11-01-2013 at 08:14 AM.

+ 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. Help in creating a macro for filtered Pivot Table
    By me154952 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2013, 04:52 AM
  2. Creating a Pivot Table using a Macro
    By lorber123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2013, 03:22 PM
  3. Creating a pivot table using Macro
    By McQLon in forum Excel General
    Replies: 1
    Last Post: 09-24-2008, 07:54 AM
  4. Macro for creating a pivot table
    By bohye in forum Excel General
    Replies: 2
    Last Post: 03-01-2008, 07:40 AM
  5. Macro for creating Pivot table?
    By henrik79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-31-2006, 07:24 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