+ Reply to Thread
Results 1 to 5 of 5

If number in column duplicated on sheet change then problen

Hybrid View

  1. #1
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,789

    Re: If number in column duplicated on sheet change then problen

    May be this,,,?

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim EvalRange As Range
        
    Set EvalRange = Range("a4:a10000")
    
    If Intersect(Target, EvalRange) Is Nothing Then Exit Sub
    If Target.Cells.Count > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    
    Target.NumberFormat = "0000"
    
    If WorksheetFunction.CountIf(EvalRange, Target.Value) > 1 Then
        MsgBox Target.Value & " has already been used." & vbCr & "Do you want to use the same number (cancel) or enter a new one (retry)?", vbInformation, "Value Already Exist"
        
        Application.EnableEvents = False
            Target.Value = ""
        Application.EnableEvents = True
    End If
    
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  2. #2
    Registered User
    Join Date
    10-24-2011
    Location
    SA, Australia
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: If number in column duplicated on sheet change then problen

    Thanks SixthSense. That works in that it sets the cell to empty however I need to allow them to re-use a number 2 or more times if they want to. I was trying to do it by using vbretry / cancel. If cancel then allow the number to stay as a duplicate.

    My code did that but when I went into another cell eg D4 and typed soemthing in then left the cell the check on A5:A1000 fires off again. It does it for every cell I change in that row.

    I need to stop the check once the focus leaves A4

    Cheers
    the old fogey

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,789

    Re: If number in column duplicated on sheet change then problen

    Quote Originally Posted by djon5020 View Post
    My code did that but when I went into another cell eg D4 and typed soemthing in then left the cell the check on A5:A1000 fires off again. It does it for every cell I change in that row.
    My suggested method of code will exit soon when the entry don't happen in Range("a4:a10000")

+ 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. [SOLVED] Automatically change sheet number when first sheet is filled in.
    By Bikeman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-29-2014, 04:36 PM
  2. [SOLVED] Conditional Format - Highlight a Cell in Sheet 2 if Duplicated from Sheet 1
    By sliesneekr in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-26-2014, 09:16 AM
  3. [SOLVED] Change all matching Value based on number change in Column Excel 2007
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 02-20-2014, 11:40 AM
  4. Match Column A's Project number to change based on greater number in new row
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2013, 10:18 AM
  5. Vlookup but change column index number as you drag to next column
    By yankeekid86 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-29-2013, 09:46 AM

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