+ Reply to Thread
Results 1 to 6 of 6

Excel Column Change

Hybrid View

jammmie999 Excel Column Change 08-02-2010, 07:26 PM
Richard Buttrey Re: Excel Column Change 08-02-2010, 07:32 PM
teylyn Re: Excel Column Change 08-02-2010, 07:34 PM
Richard Buttrey Re: Excel Column Change 08-02-2010, 07:38 PM
martindwilson Re: Excel Column Change 08-02-2010, 07:36 PM
jammmie999 Re: Excel Column Change 08-02-2010, 08:06 PM
  1. #1
    Registered User
    Join Date
    05-20-2010
    Location
    England
    MS-Off Ver
    Excel 2010 Beta
    Posts
    8

    Excel Column Change

    Hello,

    Could someone please write me a quick macro that when I edit a cell in Column A it checks the value I inputted and displays a message if it is lower than the last value. E.G.
    A1 - 0
    A2 - 1
    A3 - 2
    A4 - 0 - Display a message when this value is entered.

    All I have at the moment is this, and I cant seem to get it to work properly with my requirements.
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    
    If Target.Address = "$A$1" Then
    
    
            MsgBox "You just changed " & Target.Address
            
    End If
            
    
    End Sub
    Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel Column Change

    Hi,

    One way
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("A:A")) Is Nothing Then
            If Target < Target.Offset(-1, 0) Then
                MsgBox "your message"
            End If
        End If
    End Sub
    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Excel Column Change

    Richard, I came up with something similar, but I added a check to see if Target is in Row 1, otherwise the offset will bomb.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
        If Target.Address = "$A$1" Then Exit Sub
        If Target.Value < Target.Offset(-1, 0).Value Then
            MsgBox "Value is less than previous cell"
        End If
    End If
    End Sub
    Then again, Data Validation could be used with a similar result, VBA-free.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel Column Change

    Hi Teylyn,

    Yes agreed and a good point

    Rgds

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Excel Column Change

    you can do it with data validation
    in a2 validate as allow/custom
    =A2>=A1
    drag down
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Registered User
    Join Date
    05-20-2010
    Location
    England
    MS-Off Ver
    Excel 2010 Beta
    Posts
    8

    Re: Excel Column Change

    Thanks for the great response guys. Thanks especially to teylyn and Richard.

+ 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