+ Reply to Thread
Results 1 to 15 of 15

Vba macros to export from listview1 to new workbook

  1. #1
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    906

    Vba macros to export from listview1 to new workbook

    Hello Again to everyone,

    Can anyone help to write VBA macros to export data from listvie1 control to a new workbook.

    Sample workbook is attached for your reference.
    Attached Files Attached Files
    Last edited by hecgroups; 01-23-2015 at 10:29 AM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups

    Does the New Workbook exist or does it need to be created?

    Will the New Workbook be in the same Folder as the Source Workbook?

    If the New Workbook is to be created, how will it be Named?

    What version of Excel does it need to run in (you attached an .xls File)?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    906

    Re: Vba macros to export from listview1 to new workbook

    Hai Jaslake,

    First of all i would like to thank you to respond to my request. I will change the file version to *.xlsm once I finalized the file.

    Better idea is to create new workbook.

    If you can give me 2 option like Save or not to save a workbook.

    If not save then new workbook will be activate or If saved then the textbox1 value will be the saved workbook name.

    Kindly note that if the items more than 1048576 then it should copy a data to new sheet with header.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups

    Attach this Code to Command Button 2
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    906

    Re: Vba macros to export from listview1 to new workbook

    Hai Jaslake,

    It works but while copying the data is copying the row numbers. Can we skip the row number while copying.

    second thing I have some data which is under one million items but some I have more than 5 million items. so I just want to search multiple worksheets in a workbook.

    while copying if the data is more than a million it will select another worksheet within the same workbook and start copying the data.

    I don't know it is possible or not

  6. #6
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    906

    Re: Vba macros to export from listview1 to new workbook

    Sorry to tell you can we have count of records found on same form Label3.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups

    This is simple enough...hide Column 1 or a minor Code revision to eliminate Column 1...
    Can we skip the row number while copying
    This, I assume, can be done...
    can we have count of records found on same form Label3
    You mention this yet your Sample File does not demonstrate such.
    search multiple worksheets in a workbook
    This, I have no clue... 5 million records???...the Code may take DAYS to run...I'll not touch it with a stick. Far as I know, Excel will accommodate only 1 million records (plus some change).

    You'll need to update your Thread with a new Sample File that demonstrates what you have and what you wish it to be...I'm not seeing that at the moment.

  8. #8
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    906

    Re: Vba macros to export from listview1 to new workbook

    Thanks for the information.

    atleast can you make a search on multiple worksheets (Sample attached)

    I have set an example on userform for row count.

    let assume that I am searching foot in entire workbook. There are total 10 items in whole workbook

    I hope with this requirement my will be solved.

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups

    I'll look at it tomorrow...late here.

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups

    The Code in the attached has been modified to do this
    make a search on multiple worksheets
    and this
    Can we skip the row number while copying
    and this
    can we have count of records found on same form Label3
    I'll look at this but I have no way of testing so, don't hold your breath
    while copying if the data is more than a million it will select another worksheet within the same workbook and start copying the data.

  11. #11
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    906

    Re: Vba macros to export from listview1 to new workbook

    Thanks Jaslake,

    it is working. I thought my last post will be the last request but unfortunately I find something unusual.

    while copying the data from listvew control to new workbook it is changing the column A values.

    let say i am searching a work consult it is showing correct values on control but on worksheet the items which is starting with zeros is disappearing.

    on control 001 but on worksheet 1

    Actual data
    Service Code Service Name Service Type Price Discount Start Date
    0001 INTERNIST CONSULTION Consultation 35 0 22-02-2013

    Output on new workbook
    Service Code Service Name Service Type Price Discount Start Date
    1 INTERNIST CONSULTION Consultation 35 0 22-02-2013

    Sample workbook is attached for your reference. just search a data and export to new workbook. See the row numbers 6, 7 & you will find the values changed.

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups

    Add the indicated line of Code
    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    906

    Re: Vba macros to export from listview1 to new workbook

    Jaslake,

    Thanks a lot for your time and valuable help. You cannot imagine how much time you have saved.

    I hope their no issue. incase if I find anything can I contact you again.

    Topic marked as solved and reputation added.

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups


    You're welcome...glad I could help. Thanks for the Rep.

    If you have other issues, feel free to contact me. In the meantime I'll look at the "Splitting of Records" issue.

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Vba macros to export from listview1 to new workbook

    Hi hecgroups

    The Code in the attached has been modified to split the Records to a second Worksheet based on "myLimit" in Private Sub CommandButton2_Click().
    Please Login or Register  to view this content.
    I have it set at 10 for testing. Let me know of issues...

+ 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 with macros to export report to excel
    By Jacobmat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2014, 06:23 PM
  2. Can't access macros in personal.xlsb workbook from macros in a second workbook
    By JimFM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-24-2013, 03:35 PM
  3. I would need a macro to export data from base example workbook to export worbook
    By slato8 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2012, 11:21 AM
  4. macros to export to txt
    By ymeyaw in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-14-2006, 09:45 PM
  5. export macros
    By Ruben Mikkelsen in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-09-2005, 03:06 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