Hello I have created excel file as yearly activities calendar and it's in 2 sheets one as calendar and the other as data sheet for adding the daily activities I want want to modify this code to 8 sheets, with 2 sheets for each shift (A, B, C, and D).
My VBA as below
Dim YearNM As Long, dayCol As Long, DayRow As Long Dim dataSheet As Worksheet Dim selDate As Date
900KX
Private Sub Worksheet Change (ByVal Target As Range)
If Not Intersect (Target, Range ("AH7: AH27")) Is Nothing Then
selDate = Range ("AH6") . Value * Selected date
YearNM = [ScYear)
Determine if data worksheet exists
On Error Resume Next
Set dataSheet = ThisWorkbook. Sheets ("" & YearNM & In)
On Error GOTo O
If dataSheet Is Nothing Then
ThisWorkbook. Sheets. Add (After: -Sheets ("Schedule") ) . Name = YearNM
Set dataSheet =
ThisWorkbook. Sheets ("" & YearNM & I")
Activate
End If
DayRow = Target. Row " Row
dayCol = selDate - DateSerial (YearNM, 1, 1) + 1 ' Determine column for data sheet
dataSheet. Cells (DayRow, dayCol). Value = Target. Value
End If
End Sub
Private Sub Worksheet SelectionChange (ByVal Target As Range)
If Target. CountLarge > 1 Then Exit Sub If Not Intersect (Target, Range ("B7:AF30")) Is Nothing Then
If IsDate (Target. Value) = False Then Exit Sub
selDate = Target. Value Selected Date
YearNM = [ScYear]
Range ("AH6" ) . Value = selDate
Determine if data worksheet exists
On Error Resume Next
Set dataSheet = ThisWorkbook. Sheets ("' & YearNM & In)
On Error GOTo 0
If dataSheet Is Nothing Then
ThisWorkbook. Sheets.Add (After:-Sheets ("Schedule")) . Name = YearNM
900KX
Set dataSheet = ThisWorkbook. Sheets (n" & YearNM & "")
Activate
End If
DayRow = Target. Row * Row
dayCol = selDate - DateSerial (YearNM, 1, 1) + 1 * Determine column for data sheet
dataSheet. Cells (DayRow, dayCol) . Value = Target. Value
End If
End Sub
900K3
Private Sub Worksheet SelectionChange (ByVal Target As Range)
If Target. CountLarge > 1 Then Exit Sub
If Not Intersect (Target, Range ("B7: AF30") ) Is Nothing Then
If IsDate (Target.Value) = False Then Exit Sub
900KX
selDate = Target.Value Selected Date
YearNM = [ScYear]
Range ("AH6") .Value = selDate
Determine if data worksheet exists
On Error Resume Next
Set dataSheet = ThisWorkbook. Sheets ("" & YearNM & "i)
On Error GoTo O
If dataSheet Is Nothing Then
ThisWorkbook. Sheets. Add (After: -Sheets ("Schedule") ) . Name - YearNM Set dataSheet
= ThisWorkbook. Sheets (IT & YearNM & "")
T
Activate
End If
DayRow = Target. Row ' Row
dayCol - selDate - DateSerial (YearNM, 1, 1) + 1 Deterhine column for data sheet
Range ("AH7 : AH27") . Value - dataSheet. Range (dataSheet.Cells (7, dayCol) , datasheet. Cells (27, dayCol)) . Value
End If
End Sub
My VBA as below
Dim YearNM As Long, dayCol As Long, DayRow As Long Dim dataSheet As Worksheet Dim selDate As Date
900KX
Private Sub Worksheet Change (ByVal Target As Range)
If Not Intersect (Target, Range ("AH7: AH27")) Is Nothing Then
selDate = Range ("AH6") . Value * Selected date
YearNM = [ScYear)
Determine if data worksheet exists
On Error Resume Next
Set dataSheet = ThisWorkbook. Sheets ("" & YearNM & In)
On Error GOTo O
If dataSheet Is Nothing Then
ThisWorkbook. Sheets. Add (After: -Sheets ("Schedule") ) . Name = YearNM
Set dataSheet =
ThisWorkbook. Sheets ("" & YearNM & I")
Activate
End If
DayRow = Target. Row " Row
dayCol = selDate - DateSerial (YearNM, 1, 1) + 1 ' Determine column for data sheet
dataSheet. Cells (DayRow, dayCol). Value = Target. Value
End If
End Sub
Private Sub Worksheet SelectionChange (ByVal Target As Range)
If Target. CountLarge > 1 Then Exit Sub If Not Intersect (Target, Range ("B7:AF30")) Is Nothing Then
If IsDate (Target. Value) = False Then Exit Sub
selDate = Target. Value Selected Date
YearNM = [ScYear]
Range ("AH6" ) . Value = selDate
Determine if data worksheet exists
On Error Resume Next
Set dataSheet = ThisWorkbook. Sheets ("' & YearNM & In)
On Error GOTo 0
If dataSheet Is Nothing Then
ThisWorkbook. Sheets.Add (After:-Sheets ("Schedule")) . Name = YearNM
900KX
Set dataSheet = ThisWorkbook. Sheets (n" & YearNM & "")
Activate
End If
DayRow = Target. Row * Row
dayCol = selDate - DateSerial (YearNM, 1, 1) + 1 * Determine column for data sheet
dataSheet. Cells (DayRow, dayCol) . Value = Target. Value
End If
End Sub
900K3
Private Sub Worksheet SelectionChange (ByVal Target As Range)
If Target. CountLarge > 1 Then Exit Sub
If Not Intersect (Target, Range ("B7: AF30") ) Is Nothing Then
If IsDate (Target.Value) = False Then Exit Sub
900KX
selDate = Target.Value Selected Date
YearNM = [ScYear]
Range ("AH6") .Value = selDate
Determine if data worksheet exists
On Error Resume Next
Set dataSheet = ThisWorkbook. Sheets ("" & YearNM & "i)
On Error GoTo O
If dataSheet Is Nothing Then
ThisWorkbook. Sheets. Add (After: -Sheets ("Schedule") ) . Name - YearNM Set dataSheet
= ThisWorkbook. Sheets (IT & YearNM & "")
T
Activate
End If
DayRow = Target. Row ' Row
dayCol - selDate - DateSerial (YearNM, 1, 1) + 1 Deterhine column for data sheet
Range ("AH7 : AH27") . Value - dataSheet. Range (dataSheet.Cells (7, dayCol) , datasheet. Cells (27, dayCol)) . Value
End If
End Sub