+ Reply to Thread
Results 1 to 13 of 13

New to VBA and trying to make simple macro

  1. #1
    Registered User
    Join Date
    09-19-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2013
    Posts
    6

    New to VBA and trying to make simple macro

    Hello everyone,

    This is my first post and I hope this site can be useful. It's hard to learn VBA on your own. I'm trying to make a macro that will take check to see if any names in a column on the first sheet exist in a column on another sheet. If the name is not in the second sheet, I want it to add the new name to the end of the second column. The columns will vary in lengths and I'm not sure how to program this. Below is what I have so far. It runs but doesn't do what I would like it to do. I think my biggest issue is the language. I'm used to matlab, but I'm rusty at programing in general. Thanks for the help every one!

    Please Login or Register  to view this content.
    Last edited by arlu1201; 09-20-2013 at 01:52 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: New to VBA and trying to make simple macro

    Welcome to the Forum jman070700 from New Jersey. Its best to read the Forum Rules before posting. To get more responses you need to comply with Forum Rule No.1 and provide a more descriptive title. Also Forum Rule No3. requires you too use code tags.

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: New to VBA and trying to make simple macro

    Hi JMan,



    BTW - You should always tag your code - just highlight it and click on the #
    Last edited by xladept; 09-19-2013 at 04:41 PM. Reason: Bad Code
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    09-19-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: New to VBA and trying to make simple macro

    Thank you for the advice, I will tag my code in the future.

    I tried your code but it did not work. I filled the cells with a few random names to test it out. it's not moving the names from the first column to the second. I'm not sure if the strcomp function should be used or not.

  5. #5
    Registered User
    Join Date
    09-19-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: New to VBA and trying to make simple macro

    Also, I'm noticing that count2 is = 36 when there are only 4 names. There is nothing below those names either.

    I'm not sure why this is happening.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: New to VBA and trying to make simple macro

    I used your original code:
    Please Login or Register  to view this content.
    and didn't notice that "rows" was omitted. It should be:
    Please Login or Register  to view this content.
    - but the Used Range is often unreliable.

    As to why the code didn't work otherwise?? Can you post a sample spreadsheet? Go to advanced and click on the paper clip

  7. #7
    Registered User
    Join Date
    09-19-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: New to VBA and trying to make simple macro

    that fixed count2.

    I really appreciate all this help. I'll be sure to return the favor when I'm good enough to be able to.
    Attached Files Attached Files

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: New to VBA and trying to make simple macro

    Hi JMan,

    Try this:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-19-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: New to VBA and trying to make simple macro

    YES, that seemed to work. I'll look over your code to learn how you did this better. Thank you so much!

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: New to VBA and trying to make simple macro

    You're welcome! And - thanks for the rep

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: New to VBA and trying to make simple macro

    jman,

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    Also,

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. In order to put code tags, either type [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] at the end of it, OR you can highlight your code and click the # icon at the top of your post window.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  12. #12
    Registered User
    Join Date
    09-19-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: New to VBA and trying to make simple macro

    OK, I did't realize I titled my issue wrong. Thank you

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: New to VBA and trying to make simple macro

    Your title still needs correction. You can try changing it to "Macro to check if names match across sheets."

+ 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. Make a simple formula
    By herukuncahyono in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-11-2013, 11:56 PM
  2. I'll Try and make this simple!
    By toby1 in forum Excel General
    Replies: 3
    Last Post: 11-05-2008, 05:24 PM
  3. Simple Macro Help:How do I make it so that it does that???
    By Kaaji1359 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2008, 11:08 AM
  4. Trying to make a simple macro, need help...
    By jodanfsl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2007, 10:11 PM
  5. [SOLVED] Make it more simple or intuitive to do simple things
    By Vernie in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-16-2005, 12:06 AM

Tags for this Thread

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