+ Reply to Thread
Results 1 to 3 of 3

vb code column validation

  1. #1
    Registered User
    Join Date
    03-23-2011
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    2

    Red face vb code column validation

    Hello

    The code is setup to validate if some of the columns are left blank. The code only fires if col 'C' is populated. Otherwise it doesn't validate on the last line. I'm trying to update it so either col 'C' or 'D' has to be populated before the code fires. Appreciate any help.


    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    LstRow = Sheets(1).Range("C65536").End(xlUp).Row
    Dim FoundRange As Range
    On Error GoTo X:
    Set FoundRange = Sheets(1).Range("F8:H" & LstRow & ",J8:O" & LstRow).SpecialCells(xlCellTypeBlanks)
    FoundRange.Select
    Cancel = True
    MsgBox "In order to SAVE & EXIT, please populate the mandatory columns ('F' thru 'H' and 'J' thru 'O')."
    Exit Sub
    X:
    Cancel = False
    End Sub

  2. #2
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: vb code column validation

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-23-2011
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    2

    Red face Re: vb code column validation

    Sadath, thank you very much for your quick reply. The code you provided worked but I need to add addition columns in order to fire up. Not sure how to give you points or what not.

    I took the code you provide and tried to include col 'G' and 'H' as well but I couldn't get it to work. Therefore, I'm trying to update it so either col 'C' or 'D', 'or G' or 'H' has to be populated before the code fires. Appreciate your help again.

+ 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