+ Reply to Thread
Results 1 to 2 of 2

Macro to Compare and check two rows

Hybrid View

  1. #1
    Registered User
    Join Date
    08-08-2007
    Posts
    1

    Macro to Compare and check two rows

    I have a question that I have two rows from D77 TO D132 which is column D
    and I have column B with rows B77 till B132.

    I want to check that if a user fill anything in D77 or any row from D77 to D132 he needs to fill row against B Column.
    As an example some one put data in row D77 and didnt feed any data in B77 against that it will ask the user to put the data in B77 before saving and wont let the user save the file until he enters data against D77 row in B77.

    Can anyone help me with the macro. I am pretty new so I am not sure how to make it.

    Its basically a conditional macro that it checks the rows against D to B and verifies if D row is filled B is also filled but if B row is not filled it ask the user to fill in the data in row B before saving.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try this sheet event macro. Select the sheet tab, right click, select view code, then paste in the code.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      On Error GoTo errhand
      Application.EnableEvents = False
      For Each ce In Range("D77:D132")
        If Not IsEmpty(ce) And IsEmpty(ce.Offset(0, -2)) Then
          ce.Offset(0, -2).Select
          MsgBox "Must fill this cell"
          Exit For
        End If
      Next ce
    errhand:
      Application.EnableEvents = True
    End Sub
    If you have data in column D for the relevant range, and there is nothing in column B, then it will prompt for input.


    rylo

+ 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