Hi All
Macro to run at specific date,days and time and modulable.
That is macro will check these three criterias above to run another sub otherwise say " Not authorised any more "
sample
So date may be 01/02/2016 to 25/02/2016
Days:Monday to Thursday
or Monday , Thursday , Saturday
Time :10:10 am to 17:00 pm
It should be embedded in another macro as below and modulable to other macros if possible in order for the other sub to work
Thanks if any can help
Macro to run at specific date,days and time and modulable.
That is macro will check these three criterias above to run another sub otherwise say " Not authorised any more "
sample
So date may be 01/02/2016 to 25/02/2016
Days:Monday to Thursday
or Monday , Thursday , Saturday
Time :10:10 am to 17:00 pm
It should be embedded in another macro as below and modulable to other macros if possible in order for the other sub to work
Thanks if any can help
Code:
Sub Button1_Click()
Dim x As Long
Dim arr() As Variant
Dim temp As Variant
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim dic As Object
Const delim As String = "|"
Set ws1 = Sheets("Input Datasheet")
Set ws2 = Sheets("Product DataBase ")
Set dic = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
With ws2
For x = 1 To .Cells(.Rows.Count, 3).End(xlUp).Row
dic(Val(.Cells(x, 3).Value)) = .Cells(x, 1).Value & delim & .Cells(x, 2).Value
Next x
End With
With ws1
x = .Cells(.Rows.Count, 3).End(xlUp).Row
arr = .Cells(2, 1).Resize(x - 1, 4).Value
For x = LBound(arr, 1) To UBound(arr, 1)
If dic.exists(.Cells(x + 1, 3).Value) Then
temp = Split(dic(.Cells(x + 1, 3).Value), delim)
arr(x, 1) = temp(0)
arr(x, 2) = temp(1)
Erase temp
Else
arr(x, 1) = Empty
arr(x, 2) = Empty
End If
Next x
.Cells(2, 1).Resize(UBound(arr, 1), UBound(arr, 2)).Value2 = arr
End With
Application.ScreenUpdating = True
Set dic = Nothing
Set ws1 = Nothing
Set ws2 = Nothing
Erase arr
End Sub