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
Bookmarks