+ Reply to Thread
Results 1 to 15 of 15

Using VBA to populate cells based on a criteria in another tab

  1. #1
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Using VBA to populate cells based on a criteria in another tab

    Hi, I really want to learn VBA and its many uses in excel, but I'm more of a hands on learner. I have a simple project I'm trying to do for work that I know is possible through VBA, but I don't have the expertise to do it.

    Essentially we have a master list of property managers (PM) addresses and owners etc... in a tab called "Property List" and tabs for each of the property managers in the same file. I would like to populate the individual PM's tabs with their properties based on a search/copy/paste of the "Property List" tab

    Row 1 contains the headers ... there are 10 columns of information
    Row 2 begins the data
    Column 1 contiains the property manager Initial (the search criteria)

    I've tried this code but get a runtime error object required
    Please Login or Register  to view this content.
    Any helpful hints or suggestions is greatly appreciated. I would really like to learn this stuff so if you have suggestions on tutorials etc... I'm open!
    Last edited by mongoose36; 07-25-2013 at 09:07 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: New to VBA and want to learn

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: New to VBA and want to learn

    Wow! Awesome that worked perfectly thank you!!...would you mind walking me through the code so I can understand the arguments. I am familiar with some of the arguments having programed applescripts, but not all.

    Additionally, I want to make this dynamic...We currently have 12 property managers...in the future some may be added and some removed.

    I would like to expand this macro to say search a tab called "Property Manager List" which would contain initials and First names. The macro would then create a tab for each first name (if one doesn't exist already) then perform the operation of the code above for each Porperty managers initial. I need the code to be dynamic enough that everytime we remove and/or add a property manager I don't have to go in and change the code.

    Is this possible?

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Using VBA to populate cells based on a criteria in another tab

    I have no idea about your workbook

  5. #5
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Using VBA to populate cells based on a criteria in another tab

    I'm not quite sure how to take your answer?? If you mean you need additional information I have attached the workbook for you to look at. If on the other hand you mean you do not want to prusue this further I understand and thank you for your help thus far.
    Attached Files Attached Files

  6. #6
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Using VBA to populate cells based on a criteria in another tab

    Does anybody else have any suggestions?

  7. #7
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: New to VBA and want to learn

    Quote Originally Posted by cplettner View Post
    I need the code to be dynamic enough that everytime we remove and/or add a property manager I don't have to go in and change the code.
    you are not asking for suggestions, but for a turnkey package.

  8. #8
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: New to VBA and want to learn

    Ok?? I think I understand what you are saying. I'm willing to do this on my own if you could point me to resources I could study. I really do want to learn this stuff, but don't know where to start?
    Last edited by mongoose36; 07-26-2013 at 12:38 PM.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Using VBA to populate cells based on a criteria in another tab

    Hi, cplettner,

    work through the range of all managers, apply an Autofilter to the sheet List with each single name, copy all visible cells to a new sheet, name that sheet. Maybe have a look at this:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  10. #10
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Using VBA to populate cells based on a criteria in another tab

    GENIOUS!! I REALLY appreciate your help. I'm going through the code trying to understand all the arguments. I admit it’s a bit beyond me, but hopefully with time I will understand it all. A couple of questions.

    If I want it to change the formats as well can I simply change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Also how do we update?? If I delete some of the properties and try to run the script again it creates another sheet and gives me an error. I had to delete the newly created tabs and run the script to see the change. Perhaps the way around this is to write a script at the beginning that would delete all the tabs except for "Property Managers" and "Property List" then run the rest of the script. Your thoughts

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Using VBA to populate cells based on a criteria in another tab

    Hi, cplettner,

    there are different ways to solve this: keep the sheets and clear the contents if teh code finds a suiting name. Or as you said delete all sheets apart from the two which are part of the sample workbook.

    Itīs up to you to decide what you think is suiting your taste/situation.

    Ciao,
    Holger

  12. #12
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Using VBA to populate cells based on a criteria in another tab

    As Far as deleting the sheets I was able to get this to work:

    Please Login or Register  to view this content.
    How would do the first thing you mentioned??

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Using VBA to populate cells based on a criteria in another tab

    Hi, cplettner,

    code for keeping the sheets and only adding new ones if new names are introduced may look like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  14. #14
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Using VBA to populate cells based on a criteria in another tab

    This works wonders!! But how do I get it to delete a tab if I remove a property manager from the Property Mangers tab

  15. #15
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Using VBA to populate cells based on a criteria in another tab

    Hi, cplettner,

    two options from my point: either stay with what yoiu have right now an dthen loop thorugh all sheets and see if the name is in the list, or get your first idea out again to delete all sheets except those with data to distribute and then build the managers sheets up again.

    Ciao,
    Holger

+ 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. Need to learn VBA
    By MBeedle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2013, 03:12 PM
  2. Here to learn!
    By bigac in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 08-07-2012, 12:39 PM
  3. How to Learn VBA?
    By melleniam in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2008, 09:55 AM
  4. To learn about VBA
    By Morrigan in forum Excel General
    Replies: 3
    Last Post: 08-09-2005, 09:33 AM
  5. [SOLVED] How to learn VBA
    By Thrava in forum Excel General
    Replies: 3
    Last Post: 01-07-2005, 09: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