I have two sets of vba code. Is it possible to run them on the same sheet either simultaneously or one after the other?
Code 1:
Code 2:
Code 1:
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim rng As Range, r As Range
Set rng = Intersect(Range("AB11:BW224"), Target) 'Range as posted, adjust for real range
If rng Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each r In rng
If r.Value = "" Then r.FormulaR1C1 = "=HLOOKUP(R8C,Table5[[#All],[MON IN]:[FRI OUT]],ROW()-9,0)"
Next r
Application.EnableEvents = True
End Sub
Code 2:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$M$2" Then 'check if cell M2 was changed
Dim myRange As Range
Dim myInt As Long
Set myRange = Range("AD9")
myInt = 2
Do Until myRange.Value >= Target.Value 'go through dates until the current date is reached
If myRange.Value < Target.Value Then
Do Until IsEmpty(myRange.Offset(myInt, 0)) 'go down columns and replace with values
myRange.Offset(myInt, 0).Value = myRange.Offset(myInt, 0).Value
myInt = myInt + 1
Loop
myInt = 2
End If
Set myRange = myRange.Offset(0, 1)
Loop
End If
End Sub