+ Reply to Thread
Results 1 to 2 of 2

mandatory cells only if another cell is filled

  1. #1
    RA
    Guest

    mandatory cells only if another cell is filled

    I have checked other postings regarding VBA codes for making cells mandatory
    if another cell is filled. I have tried the different statements in various
    postings but they did not work for me. I need to have C38 mandatory only if
    A38 is filled. I also need this condition up to row 46. If cells in column
    A are filled then the corresponding rows in column C have to be filled,
    otherwise, the file cannot be saved.

    Thanks.

  2. #2
    Tom Ogilvy
    Guest

    RE: mandatory cells only if another cell is filled

    in the thisworkbook module:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    set rng = Worksheets("Sheet1").Range("A38:A46")
    for each cell in rng
    if not isempty(cell) and isempty(cell.offset(0,2)) then
    Application.Goto cell.offset(0,2)
    Cancel = True
    msgbox "Please fill in cells in column C for " & _
    vbNewLine & "corresponding filled in cells in column A in rows "
    & vbNewLine & "38 to 46. Save is cancelled!"
    end if
    Next
    End Sub

    --
    Regards,
    Tom Ogilvy


    "RA" wrote:

    > I have checked other postings regarding VBA codes for making cells mandatory
    > if another cell is filled. I have tried the different statements in various
    > postings but they did not work for me. I need to have C38 mandatory only if
    > A38 is filled. I also need this condition up to row 46. If cells in column
    > A are filled then the corresponding rows in column C have to be filled,
    > otherwise, the file cannot be saved.
    >
    > Thanks.


+ 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