+ Reply to Thread
Results 1 to 5 of 5

macro to check if a value exist in sheet and add it if it doesnt

  1. #1
    Registered User
    Join Date
    08-29-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    macro to check if a value exist in sheet and add it if it doesnt

    Hi,

    I need help from you experts on this problem I'm having:

    I've attached a sample workbook with the post.

    I need a macro to go through the values in column A in the "reference" tab and check if the value already exist in column B in "master" sheet. If it does, then do nothing for that cell and continue on to the next cell, if it doesn't exist then add all three values for that row (column A, B and C) to the end of the table in "master" sheet and then go to the next cell. Go through all the values in column A in the "reference" tab.

    Please help.
    Attached Files Attached Files
    Last edited by RetroGun; 08-29-2011 at 10:43 PM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: macro to check if a value exist in sheet and add it if it doesnt

    RetroGun,

    Welcome to the Excel Forum.


    Detach/open workbook UpdateMaster wR c wM NR - RetroGun - EF790131 - SDG10.xlsm and run macro UpdateMaster.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    08-29-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: macro to check if a value exist in sheet and add it if it doesnt

    wow... I couldn't figure that out after 4 hours of trying... Thanks a lot. I'm facing a similar, but slightly different problem now (I seem to suck at programming)

    I need a macro to go through the values in column A in the "reference" tab and check if the value already exist in column B in "master" sheet. If it does, then copy respective value from column C and paste it to column F in the "master" sheet. If it doesn't exist then add column A and B values to the end of the table in "master" sheet and add column C value to "master" column F. Go through all the values in column A in the "reference" tab.

    Thanks in advance for your help. I've attached another sample workbook for this.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: macro to check if a value exist in sheet and add it if it doesnt

    RetroGun,

    Detach/open workbook UpdateMasterV2 wR c wM NR and col F - RetroGun - EF790131 - SDG10.xlsm and run macro UpdateMasterV2.


    You now have two different macros for two different worksheets named Master (different layouts). One macro can be written to accomodate both layouts for worksheet Master.



    I seem to suck at programming

    Training / Books / Sites

    How to Learn to Write Macros
    http://articles.excelyogi.com/playin...ba/2008/10/27/

    How to use the macro recorder
    http://articles.excelyogi.com/

    Click here and scroll down to Getting Started with VBA.
    http://www.datapigtechnologies.com/ExcelMain.htm

    If you are serious about learning VBA try
    http://www.add-ins.com/vbhelp.htm

    Excel Tutorials and Tips - VBA - macros - training
    http://www.mrexcel.com/articles.shtml

    See David McRitchie's site if you just started with VBA
    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    What is a Visual Basic Module?
    http://www.emagenit.com/VBA%20Folder...vba_module.htm

    Debra Dalgleish has some notes how to implement macros here:
    http://www.contextures.com/xlvba01.html

    David McRitchie has an intro to macros:
    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    Ron de Bruin's intro to macros:
    http://www.rondebruin.nl/code.htm

    Creating custom functions
    http://office.microsoft.com/en-us/ex...117011033.aspx

    Writing Your First VBA Function in Excel
    http://www.exceltip.com/st/Writing_Y...Excel/631.html

    Where to paste code in VBE VBA
    Introducing the Excel VBA Editor
    http://www.ask.com/web?qsrc=2417&o=1...cel+VBA+Editor

    VBA for Excel (Macros)
    http://www.excel-vba.com/excel-vba-contents.htm

    VBA Lesson 11: VBA Code General Tips and General Vocabulary
    http://www.excel-vba.com/vba-code-2-1-tips.htm

    Excel VBA -- Adding Code to a Workbook
    http://www.contextures.com/xlvba01.html

    http://www.excel-vba.com/
    http://www.mvps.org/dmcritchie/excel/getstarted.htm
    http://www.exceltip.com/excel_links.html

    (livelessons video)
    Excel VBA and Macros with MrExcel
    ISBN: 0-7897-3938-0
    http://www.amazon.com/Excel-Macros-M...7936479&sr=1-1

    Excel Tutorials / Video Tutorials - Functions
    http://www.contextures.com/xlFunctions02.html

    http://www.xl-central.com/index.html

    http://www.datapigtechnologies.com/ExcelMain.htm

    Cascading queries

    http://www.tushar-mehta.com/excel/ne...ing_dropdowns/

    Excel VLOOKUP Function and VLOOKUP Example
    http://www.contextures.com/xlFunctions02.html

    INDEX MATCH - Excel Index Function and Excel Match Function
    http://www.contextures.com/xlFunctions03.html

    http://www.contextures.com/xlDataVal02.html
    http://www.contextures.com/xlDataVal05.html
    http://www.contextures.com/xlDataVal08.html#Larger

    Excel Data Validation - Add New Items
    http://www.contextures.com/excel-dat...ation-add.html

    Programming The VBA Editor - Created by Chip Pearson at Pearson Software Consulting LLC
    This page describes how to write code that modifies or reads other VBA code.
    http://www.cpearson.com/Excel/vbe.aspx

    Locating files containing VBA
    Searching Files in Subfolders for VBA code string:
    http://www.dailydoseofexcel.com/arch...a-code-string/

    http://www.pcreview.co.uk/forums/thread-978054.php

    Excel 2003 Power Programming with VBA (Excel Power Programming With Vba)
    by John Walkenbach

    VBA and Macros for Microsoft Excel, by Bill Jelen "Mr.Excel" and Tracy Syrstad

    Excel Hacks 100 Industrial-Strength Tips & Tools, by David & Traina Hawley

    VBA and Macros for Microsoft Excel 2007, by Bill Jelen "Mr.Excel" and Tracy Syrstad

    Excel 2007 Book: you can try this...there is a try before you buy ebook available at this link…
    http://www.mrexcel.com/learnexcel2.shtml

    Professional Excel Development
    by Stephen/ Bovey, Rob/ Green, John Bullen (Paperback - Feb 11, 2005)

    Excel 2002 VBA: Programmers Reference
    by Rob Bovey, Stephen Bullen, John Green, and Robert Rosenberg (Paperback - Sep 26, 2001)

    VB & VBA in a Nutshell: The Language
    (http://www.amazon.co.uk/VB-VBA-Nutsh...4671189&sr=1-2)

    Writing Excel Macros with VBA
    (http://www.amazon.co.uk/Writing-Exce...4671189&sr=1-3)

    User Form Creation
    http://www.contextures.com/xlUserForm01.html

    DonkeyOte: My Recommended Reading
    Volatility
    http://www.decisionmodels.com/calcsecretsi.htm

    Sumproduct
    http://www.xldynamic.com/source/xld.SUMPRODUCT.html
    http://www.xldynamic.com/source/xld.SUMPRODUCT.html

    Arrays
    http://www.xtremevbtalk.com/showthread.php?t=296012

    Pivot Intro
    http://peltiertech.com/Excel/Pivots/pivotstart.htm

    Sync Pivot Tables
    http://www.mrexcel.com/forum/showthr...g+pivot+tables
    Check out rorya's post at the very bottom of this link. It should do the trick:
    http://www.experts-exchange.com/Soft..._22844558.html
    Multiple pivot tables 1 filter to control all
    http://www.excelforum.com/excel-prog...ntrol-all.html

    Email from XL - VBA
    http://www.rondebruin.nl/sendmail.htm

    Outlook VBA
    http://www.outlookcode.com/article.aspx?ID=40

    Function Dictionary
    http://www.xlfdic.com/

    Function Translations
    http://www.piuha.fi/excel-function-name-translation/

    Dynamic Named Ranges
    http://www.contextures.com/xlNames01.html

    How to create Excel Dashboards
    http://www.contextures.com/excel-dashboards.html
    http://chandoo.org/wp/excel-dashboards/
    http://chandoo.org/wp/management-dashboards-excel/
    http://www.exceldashboardwidgets.com/

    Excel Dashboard / Scorecard Ebook
    http://www.qimacros.com/excel-dashboard-scorecard.html

    Mike Alexander from Data Pig Technologies
    Excel 2007 Dashboards & Reports For Dummies

  5. #5
    Registered User
    Join Date
    08-29-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: macro to check if a value exist in sheet and add it if it doesnt

    Thanks a lot. Problem was resolved!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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