+ Reply to Thread
Results 1 to 10 of 10

How to compare if a value inside a cell is the same

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Question How to compare if a value inside a cell is the same

    Dear Everyone,

    I am wondering if you can write me a VBA code for comparing the value inside a cell.
    Please Login or Register  to view this content.
    Thank you for your support,

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: How to compare if a value inside a cell is the same

    Like this?

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-30-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: How to compare if a value inside a cell is the same

    Dear rvasquez

    thank you for your help, what if i want to find the value in Sheets("sheet1").Cells(i, 1) in Sheets("sheet2"). column "A"
    how can i modifies the code?
    Simply I want to find the value of Sheets("sheet1").Cells(i, 1) in sheet 2, column 1, it can be in 1st row or 100th row,
    Last edited by Cutter; 08-02-2012 at 08:09 PM. Reason: Removed whole post quote

  4. #4
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: How to compare if a value inside a cell is the same

    Okay, and do what with the found cell?

  5. #5
    Registered User
    Join Date
    07-30-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: How to compare if a value inside a cell is the same

    Add 1 to column 2, if find again add another 1 i.e. become 2
    Attached Files Attached Files
    Last edited by Cutter; 08-02-2012 at 08:11 PM. Reason: Removed whole post quote

  6. #6
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: How to compare if a value inside a cell is the same

    I'm sorry from what you provided you just want unique values added to sheet2? If this is not the case could you please revise your attachement and format sheet two to mimic what you would your results to look like?

    Thanks!

  7. #7
    Registered User
    Join Date
    07-30-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: How to compare if a value inside a cell is the same

    rvasquez,

    No, that right, I have edited the file for what i expected to get.
    Attached Files Attached Files
    Last edited by Cutter; 08-02-2012 at 08:10 PM. Reason: Removed whole post quote

  8. #8
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: How to compare if a value inside a cell is the same

    Please Login or Register  to view this content.

    You could also achieve the same result by placing the formula in B1 and copying it down to the last row

    Please Login or Register  to view this content.
    To insert the macro above into your workbook:

    1.Press Alt+F8 on your keyboard
    2.Clear the macro name box and type LocateCells in the blank box provided
    3.Select the Create option
    4.In between the Sub LocateCells() and End Sub copy and paste the above code I have provided. Anything that appears in green is a comment.
    5.Exit out of the Visual Basic Window
    6.Press Alt+F8 again and this time select the LocateCells macro
    7.Select Run

  9. #9
    Registered User
    Join Date
    07-30-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: How to compare if a value inside a cell is the same

    rvasquez,
    Thank you for your help,
    your code is valid only if same date available in sheet 2 compared to sheet 1. but, what if there is nothing in sheet 2? I found that the code is not working,
    I do understand that i can do it through formula be i prefer VBA,
    Last edited by Cutter; 08-04-2012 at 11:46 AM. Reason: Removed whole post quote

  10. #10
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: How to compare if a value inside a cell is the same

    If it's not found then it should give you a 0.

+ 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