Results 1 to 1 of 1

excel vba cell check

Threaded View

  1. #1
    Registered User
    Join Date
    10-22-2011
    Location
    Jurmala
    MS-Off Ver
    Excel 2007
    Posts
    1

    excel vba cell check

    hi. I am trying to get done this table using macro, which starts at the same time when someone makes changes in worksheet

    Task:
    Table with 22 rows, 2 columns

    First row fill

    .....Sep.....|........17.....
    ................|.................
    ................|.................
    ................|.................

    1) you can fill next row ActiveCell.offset(1,0) only when previous row ActiveCell.offset(-1,0) is full. I was able to complete this task

    2) Next. if previous row, cell ActiveCell.offset(-1,0) month is "Sep" then ActiveCell you should be able to choose between Sep and Oct. But if previous row, cell ActiveCell.offset(-1,0) month is Oct then u should choose only Oct

    I already made Sep and Oct with data validation.

    This is my code

    Sub Month_date_check()
    
    For RowNum = 4 To 22
    
      If IsEmpty(ActiveCell) = False And IsEmpty(ActiveCell.Offset(-1, 0)) = True Then
        MsgBox "Please fill month in previous row to continue", vbExclamation, "Error!"
        Application.Undo
       
             ElseIf IsEmpty(ActiveCell) = True And IsEmpty(ActiveCell.Offset(-1, 0)) = False Then
             
                       If ActiveCell.Offset(-1, 0).Text = "Sep" Then
                               ActiveCell.Validation.Add,  xlValidateList, xlValidAlertStop, xlBetween, "sep;oct"
                             
                      ElseIf ActiveCell.Offset(-1, 0).Text = "Oct" Then
                               ActiveCell.Text = "Oct"
                             
      End If
     
    Next RowNum
    
    End Sub
     
    -----------------------------------------------------------------------------------------------------
     
    Private Sub Worksheet_Change(ByVal Target As Range)
     
    Application.EnableEvents = False
     
    Call Month_date_check
     
    Application.EnableEvents = True
     
    End Sub
     
    ------------------------------------------------------------------------------------------------------


    Also i wanted to add.... I use Application.EnableEvents = False, Application.EnableEvents = True
    so this For to Next RowNum loop doesn't become never-ending.

    Also i wanted to achieve, that this code does not complete all table automatically, for instance, if it finds out that previous month is Oct then it fills all next rows with "Oct" thats the wrong way.

    If user chooses Oct then it should be a chance to choose between Sep and Oct, But if user chooses Sep again then it should show message "After Oct you can choose only Oct"

    sorry for my bad english

    hope for response
    Last edited by kazenieks_leo; 10-22-2011 at 11:27 AM.

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