+ Reply to Thread
Results 1 to 4 of 4

Cell compare and highlight macro allowing user to select data ranges

Hybrid View

  1. #1
    Registered User
    Join Date
    08-14-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Cell compare and highlight macro allowing user to select data ranges

    Hi everyone. I have a macro (see below) that takes two code-defined worksheets from two workbooks and compares the data, colour highlighting any differences between cells in both worksheets.

    However, what I would like to do is have this changed so that a popup window appears when the macro is run, prompting the user to select one range of data and then select a second set, then go on and have those selections compared. If this is not possible then perhaps the user could define which sheets/books are to be compared somehow (dropdown list, manually clicking?) rather than having to define them first in the code.

    Any help much appreciated,

    Nick, Cambridge, England




    Sub Compare_Sheets()
    
    Set From_WS = Workbooks( "Book1").Worksheets("Sheet1")
    Set To_WS = Workbooks("Book2").Worksheets("Sheet2")
    
    Total_Rows = From_WS. Cells(1, 1). CurrentRegion. Rows. Count
    Total_Columns = To_WS. Cells(1, 1). CurrentRegion. Columns. Count
    
    For Rows_Counter = 1 To Total_Rows
    For Column_Counter = 1 To Total_Columns
    If Trim( LCase( From_WS. Cells( Rows_Counter, Column_Counter). Value)) <> _
    Trim( LCase( To_WS. Cells( Rows_Counter, Column_Counter). Value)) Then
    From_WS.Cells( Rows_Counter, Column_Counter). Interior. ColorIndex = 4
    To_WS.Cells( Rows_Counter, Column_Counter). Interior.ColorIndex = 5
    End If
    Next Column_Counter
    Next Rows_Counter
    End Sub
    Last edited by Nikalin; 08-15-2010 at 07:37 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: allow user selections rather than defined WS

    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.

    EDITED THIS TIME ONLY
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    08-14-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Cell compare and highlight macro; allow user to select data range

    Apologies, hopefully the title is now more succinct. Again, any help with adding a user prompt to select data ranges most appreciated. Nick

  4. #4
    Registered User
    Join Date
    08-14-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Cell compare and highlight macro allowing user to select data ranges

    Any help on calling up a dialogue box for the user?

+ 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