+ Reply to Thread
Results 1 to 10 of 10

Assistance on VBA code to extract data

  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    20

    Assistance on VBA code to extract data

    I have created a database and a userform . I have two sheets, Sheet 2 has a command button the opens up the userform and Sheet1 records that data that is entered into the form. I want to add a command button for the end users to press and it extracts the data entered onn the form and will place onto an existing workbook saved on my desk top. The command button to extract the data has been added to the form already and I have labled it "ReportButton". I need assistance. the code i attempted to use didnt function.
    Last edited by Sway1978; 04-16-2013 at 08:00 PM. Reason: issue has been resolved

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,788

    Re: Assistance on VBA code to extract data

    Uploading the file makes it easier to help you.

    Alf

  3. #3
    Registered User
    Join Date
    10-25-2012
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    20

    Re: Assistance on VBA code to extract data

    My apologies - here is a blank template I have been playing with.

    blank tester.xlsm

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,788

    Re: Assistance on VBA code to extract data

    Ouch! It seems I bite off more than I can chew but I’ll do my best and hopefully other forum members will join in.

    Alf

  5. #5
    Registered User
    Join Date
    10-25-2012
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    20

    Re: Assistance on VBA code to extract data

    No worries- everything functions perfectly - except the blank command button on the user form. Ideally the end user will click the blank button and it will extract all the data that has been entered onto Sheet 1 and either auto send to a new untitled workbook or send to outlook as an attachement, either way would work. Everything I have attempted to write hasnt functioned. So, any assistance I can get will be amazing.

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,788

    Re: Assistance on VBA code to extract data

    Ok I'm going to give it a try so here we go.

    Please Login or Register  to view this content.
    The part I'm unsure about is the "Private Sub ReporttButton_Click" is this the right name?

    The line "Offset(1)" removes the heading when copying from Sheet1. If you do wish to include heading when you copy remove the "Offset(1)" part.

    You will also need to change the path and file name to your needs.

    Alf

  7. #7
    Registered User
    Join Date
    10-25-2012
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    20

    Re: Assistance on VBA code to extract data

    Sadly, I have altered and inserted the code and when I click the command button it does nothing.

  8. #8
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,788

    Re: Assistance on VBA code to extract data

    Strange I got it to work.

    Did you set it up like this?

    Right click on tab sheet2.

    Click on “View code”

    Find “Forms” and below that there is a small square named “DinnerPlannerUserform”

    Right click on this and click on “View code”

    In the right hand window scroll down until you find “Private Sub ReporttButton1_Click()”

    Insert this part of the code after changing "C:\Users\05n\Desktop\Book1.xlsm" between "Private Sub ReporttButton1_Click()”
    and "End Sub"

    Please Login or Register  to view this content.
    To test click on the black square in the userform in Sheet2.

    Alf

  9. #9
    Registered User
    Join Date
    10-25-2012
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    20

    Re: Assistance on VBA code to extract data

    Alf it worked perfectly this time, how odd. Thank you so much for your assistance with this. I was pulling my hair out trying to get the code to work. of course I am bald now LOL thanks again

  10. #10
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,788

    Re: Assistance on VBA code to extract data

    worked perfectly this time, how odd
    Could it have been the name? I guessimated "Private Sub ReporttButton_Click()" but the real name was “Private Sub ReporttButton1_Click()”. Oh well no matter as it works now.

    Since you problem is solved could you please mark you thread "Solved"

    Alf

    Ps
    To mark your thread solved do the following:
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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