I need yur help with VBA

Aljuhahs

New Member
Joined
Sep 5, 2023
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,215,174
Messages
6,123,454
Members
449,100
Latest member
sktz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top