+ Reply to Thread
Results 1 to 12 of 12

new to macro. seeking help on select range with defined minimum.

  1. #1
    Registered User
    Join Date
    01-02-2013
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    9

    new to macro. seeking help on select range with defined minimum.

    HI All, I am new to macro and vba so please bear me with.

    i am trying to setup macro to select and copy over data from one sheet to another. for example:

    Column A is name, Column B would be $ amount. Data is sorted from largest $ to smallest $. I will need to have macro copy over all data where B $ is >$500.

    I did a macro record as follow:

    Range("A1:AC491").Select
    Range("AC491").Activate


    Another question is if I want to copy over all data from one sheet to the other. How do I have macro always select the last row of data?

    Both questions are based on rows in spreadsheet changes every time I refresh data. So I have macro in personal macro and run it against every new sheet where the >$500 and last row would be on different row...

    Hope i have made myself clear...

    Thanks for your help!
    Last edited by aballoonflies; 01-02-2013 at 10:21 PM.

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: new to macro. seeking help on select range with defined minimum.

    You could use autofilter with criteria > 500 - see attached workbook
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    01-02-2013
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: new to macro. seeking help on select range with defined minimum.

    Thanks!!
    Hate to ask..but what about copying over all data above last row of a dataset?

  4. #4
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: new to macro. seeking help on select range with defined minimum.

    You will need to upload a sample workbook with no sensitive data so I can see what you are trying to do - explain what needs to be copied and where it needs to go otherwise I am just making assumptions

  5. #5
    Registered User
    Join Date
    01-02-2013
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: new to macro. seeking help on select range with defined minimum.

    Sample.xlsx
    Sample Maually Done what Marco should do.xlsx

    HI...I have uploaded two files. Maybe it's got a bit more than what I have asked in original post. But I will give a shot to see if anyone can help me out

    "Sample" lists out all the steps.
    The other "Sample Manually Done" is what the workbook should look like after all macro are performed (You may already know I am trying to let Macro take my manual work)

    I have been playing with smuzoen's code but I really dont have the VBA basics yet to extend further. I do plan to read more but in the meantime I hope to fix this up quickly...

    Thanks for all of your support! This forum is truly helpful! Been browsing and searching as well

  6. #6
    Registered User
    Join Date
    01-02-2013
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: new to macro. seeking help on select range with defined minimum.

    Also for all the user input (Start Date, End Date, Type, Threshold), ideally I would like to put it in a separate tab...

  7. #7
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: new to macro. seeking help on select range with defined minimum.

    See attached workbook - you may have to modify it to your exact specifications however it should get you well on the way - the criteria is entered on first page.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-02-2013
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: new to macro. seeking help on select range with defined minimum.

    I cant say how much thank you I owe you
    I am learning from your code and making some changes. And encounter yet some more questions:

    on Ln72 where create Pivot Table, if I already have the pivot then I can replace these with a code that tells macro to refresh pivot base on ws2 right? Reason being the data will be much bigger, recreate pivottable every time data refreshes will probably take longer.

    and for Ln91, copy pivot table. Actually what I need to do is copy over the pivot which the subtotal of a person is larger than the threshold. So let's say we set threshold to be 2600, then only "John" will be copied over to Summary. Is there a way to have Macro look at subtotal of each Name?

    Thank you so much smuzoen!! really appreciate it!

  9. #9
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: new to macro. seeking help on select range with defined minimum.

    You will need to recreate the Pivot Table in the workbook - All the code will do is refresh the data rather than recreate it. I have changed the code so only the Subtotal is checked and if greater than the criteria then copied to summary. Hope this is what you need.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-02-2013
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: new to macro. seeking help on select range with defined minimum.

    Is there a way to copy over not just subtotal over to summary?

    Say in pivot i have below. Set threshold to be 2000
    John a 500
    b 1000
    c 1000
    John Total 2500
    Ken a 500
    b 800
    Ken Total 1300
    Jen a 1500
    b 1500
    Jen total 3000

    Then in summary, i can have:
    John a 500
    b 1000
    c 1000
    John Total 2500
    Jen a 1500
    b 1500
    Jen Total 3000

  11. #11
    Registered User
    Join Date
    01-02-2013
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: new to macro. seeking help on select range with defined minimum.

    still trying to figure out...

  12. #12
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: new to macro. seeking help on select range with defined minimum.

    See attached workbook - if you had a try always post your code as it is the only way to learn.
    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)

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