+ Reply to Thread
Results 1 to 11 of 11

Macro to create a database

  1. #1
    Registered User
    Join Date
    12-10-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    6

    Macro to create a database

    So, I have 2 sheets. Sheet 1 has details of grades of class students. There's a submit button. I need to assign a macro to this button that will copy the data from sheet 1 and paste it in sheet 2 in respective columns. So, every time you punch info in sheet 1 and press submit button it should add a new line item in sheet 2 table. May need to paste special values so that when to enter new info in sheet 1 data in sheet 2 gets entered in next row.
    Code should also enter the date on which submit button was pressed.
    Attached Files Attached Files
    Last edited by Sonofabhandari; 12-10-2020 at 04:49 AM.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,313

    Re: Macro to create a database

    Sheet full of nothingness or invisible font ??????

  3. #3
    Registered User
    Join Date
    12-10-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    6

    Re: Macro to create a database

    Sorry. Added a new sheet now.

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,313

    Re: Macro to create a database

    give this a try - macro on button
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-10-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    6

    Re: Macro to create a database

    Hey, This works perfectly. Thanks.
    However, I am trying to do the same in a work file. I see you have not added any macro. There is a code in VBA. I tried to replicate it. Changed cell references. But doing just that didn't work. Can you guide me step by step?
    First add a blank table with headers on sheet1?
    Then insert button? But you didn't assign any macro to it. I am sorry I have no background in macros and coding.

  6. #6
    Registered User
    Join Date
    12-10-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    6

    Re: Macro to create a database

    This is the code that should work for me-

    Please Login or Register  to view this content.

    My table name is Table1. It table has 5 columns.
    Sheet 1 name is Sheet1
    & Sheet2 Name of Sheet2 (on this sheet I inserted the table with appropriate column headings)

    So I added a command button and then pasted this code.
    Now I am getting a range out of script error.

    getting an error in this line of code - Set tbl1 = ws2.ListObjects("Table1")
    What am I doing wrong? checked the name of the table. Its Table1
    Last edited by Sonofabhandari; 12-10-2020 at 07:41 AM.

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,313

    Re: Macro to create a database

    see forum rule 2.
    this enables anyone helping you to copy your code and any formatting.
    if you just type it in the post it could be full of typos (errors) which causes added confusion
    I will reply when you have edited your previous post

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

  8. #8
    Registered User
    Join Date
    12-10-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    6

    Re: Macro to create a database

    Hey, It's done. Sorry for that.

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,313

    Re: Macro to create a database

    is your code in Sheet1 module ?
    failing that upload your workbook it is then a lot easier to see what is wrong.
    follow big yellow banner for instructions - how to upload - paperclip attachment does not work

  10. #10
    Registered User
    Join Date
    12-10-2020
    Location
    India
    MS-Off Ver
    2016
    Posts
    6

    Re: Macro to create a database

    Hey, I have attached the work sheet. I want to add a submit button that will add Sr. No., Date of pressing the button, Weave (C2),
    Construction (C3) & Greige Fabric Cost Total (I12) in the Database sheet table.
    So, every time you enter a new weave and construction, all the info along with
    calculated cost should get added to the next sheet table creating a database.
    Thank you.
    Attached Files Attached Files

  11. #11
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,313

    Re: Macro to create a database

    attached file - code on SUBMIT button - in Sheet1 module.
    note file now saved as a macro enabled workbook.
    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. Replies: 10
    Last Post: 03-12-2019, 01:04 AM
  2. [SOLVED] Macro to create a Database of a flat Data with Merged headings
    By sameer79 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-27-2018, 03:15 PM
  3. [SOLVED] Macro to create a Database from existing Data
    By rehana402003 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-05-2017, 09:53 PM
  4. Trying to create a macro to update a large database easily
    By SETH777 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-26-2016, 07:28 PM
  5. Looking for Flexible Macro to Create Table into Rows for Database
    By alex20850x in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2015, 10:07 PM
  6. Macro to create invoice from changing database
    By travissickle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2015, 11:09 PM
  7. Replies: 3
    Last Post: 02-24-2013, 11:43 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