Hey guys,
I have created some VBA code which I think is very inefficient for the task that it completes.
The purpose: Every time the "Budtender List" is updated, the user can click an image and run a macro. The macro is designed to copy the list (currently defined as "A1:a100", which is not dynamic) to the End of Month Worksheet and each worksheet that is greater than or equal to today. Each tab is named "##", to represent a day of the month. For today, 5/6/2016, the macro pastes the list into tabs 6,7,...,30,31,EOM.
The code is pasting into tables, and it would be awesome if the length of the table was defined by the length of the Budtender list. Also, if the code would copy down the formulas in rows C, E, & F to match the length of the Budtender List, that would be awesome!!
If anyone has improvements to this code, I would be greatly appreciative.
The code is below:
Sub Budtender_List()
Application.OnKey "^r", "Budtender_List"
Dim ws1 As Worksheet
Dim ws2 As Worksheet
...
Dim ws31 As Worksheet
Dim BL As Worksheet
Dim EOM As Worksheet
Set ws1 = Sheets("1")
Set ws2 = Sheets("2")
...
Set ws31 = Sheets("31")
Set BL = Sheets("Budtender List")
Set EOM = Sheets("End of Month")
BL.Range("A1:A100").Copy _
EOM.Range("A1:a100")
If (Date <= DateSerial(Year(Now), Month(Now), 1)) Then
BL.Range("A1:A100").Copy _
ws1.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 2)) Then
BL.Range("A1:A100").Copy _
ws2.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 3)) Then
BL.Range("A1:A100").Copy _
ws3.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 4)) Then
BL.Range("A1:A100").Copy _
ws4.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 5)) Then
BL.Range("A1:A100").Copy _
ws5.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 6)) Then
BL.Range("A1:A100").Copy _
ws6.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 7)) Then
BL.Range("A1:A100").Copy _
ws7.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 8)) Then
BL.Range("A1:A100").Copy _
ws8.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 9)) Then
BL.Range("A1:A100").Copy _
ws9.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 10)) Then
BL.Range("A1:A100").Copy _
ws10.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 11)) Then
BL.Range("A1:A100").Copy _
ws11.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 12)) Then
BL.Range("A1:A100").Copy _
ws12.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 13)) Then
BL.Range("A1:A100").Copy _
ws13.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 14)) Then
BL.Range("A1:A100").Copy _
ws14.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 15)) Then
BL.Range("A1:A100").Copy _
ws15.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 16)) Then
BL.Range("A1:A100").Copy _
ws16.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 17)) Then
BL.Range("A1:A100").Copy _
ws17.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 18)) Then
BL.Range("A1:A100").Copy _
ws18.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 19)) Then
BL.Range("A1:A100").Copy _
ws19.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 20)) Then
BL.Range("A1:A100").Copy _
ws20.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 21)) Then
BL.Range("A1:A100").Copy _
ws21.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 22)) Then
BL.Range("A1:A100").Copy _
ws22.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 23)) Then
BL.Range("A1:A100").Copy _
ws23.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 24)) Then
BL.Range("A1:A100").Copy _
ws24.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 25)) Then
BL.Range("A1:A100").Copy _
ws25.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 26)) Then
BL.Range("A1:A100").Copy _
ws26.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 27)) Then
BL.Range("A1:A100").Copy _
ws27.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 28)) Then
BL.Range("A1:A100").Copy _
ws28.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 29)) Then
BL.Range("A1:A100").Copy _
ws29.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 30)) Then
BL.Range("A1:A100").Copy _
ws30.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 31)) Then
BL.Range("A1:A100").Copy _
ws31.Range("a1:a100")
End If
End Sub
Thank you for your help,
-Azimm
I have created some VBA code which I think is very inefficient for the task that it completes.
The purpose: Every time the "Budtender List" is updated, the user can click an image and run a macro. The macro is designed to copy the list (currently defined as "A1:a100", which is not dynamic) to the End of Month Worksheet and each worksheet that is greater than or equal to today. Each tab is named "##", to represent a day of the month. For today, 5/6/2016, the macro pastes the list into tabs 6,7,...,30,31,EOM.
The code is pasting into tables, and it would be awesome if the length of the table was defined by the length of the Budtender list. Also, if the code would copy down the formulas in rows C, E, & F to match the length of the Budtender List, that would be awesome!!
If anyone has improvements to this code, I would be greatly appreciative.
The code is below:
Sub Budtender_List()
Application.OnKey "^r", "Budtender_List"
Dim ws1 As Worksheet
Dim ws2 As Worksheet
...
Dim ws31 As Worksheet
Dim BL As Worksheet
Dim EOM As Worksheet
Set ws1 = Sheets("1")
Set ws2 = Sheets("2")
...
Set ws31 = Sheets("31")
Set BL = Sheets("Budtender List")
Set EOM = Sheets("End of Month")
BL.Range("A1:A100").Copy _
EOM.Range("A1:a100")
If (Date <= DateSerial(Year(Now), Month(Now), 1)) Then
BL.Range("A1:A100").Copy _
ws1.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 2)) Then
BL.Range("A1:A100").Copy _
ws2.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 3)) Then
BL.Range("A1:A100").Copy _
ws3.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 4)) Then
BL.Range("A1:A100").Copy _
ws4.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 5)) Then
BL.Range("A1:A100").Copy _
ws5.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 6)) Then
BL.Range("A1:A100").Copy _
ws6.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 7)) Then
BL.Range("A1:A100").Copy _
ws7.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 8)) Then
BL.Range("A1:A100").Copy _
ws8.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 9)) Then
BL.Range("A1:A100").Copy _
ws9.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 10)) Then
BL.Range("A1:A100").Copy _
ws10.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 11)) Then
BL.Range("A1:A100").Copy _
ws11.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 12)) Then
BL.Range("A1:A100").Copy _
ws12.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 13)) Then
BL.Range("A1:A100").Copy _
ws13.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 14)) Then
BL.Range("A1:A100").Copy _
ws14.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 15)) Then
BL.Range("A1:A100").Copy _
ws15.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 16)) Then
BL.Range("A1:A100").Copy _
ws16.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 17)) Then
BL.Range("A1:A100").Copy _
ws17.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 18)) Then
BL.Range("A1:A100").Copy _
ws18.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 19)) Then
BL.Range("A1:A100").Copy _
ws19.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 20)) Then
BL.Range("A1:A100").Copy _
ws20.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 21)) Then
BL.Range("A1:A100").Copy _
ws21.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 22)) Then
BL.Range("A1:A100").Copy _
ws22.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 23)) Then
BL.Range("A1:A100").Copy _
ws23.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 24)) Then
BL.Range("A1:A100").Copy _
ws24.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 25)) Then
BL.Range("A1:A100").Copy _
ws25.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 26)) Then
BL.Range("A1:A100").Copy _
ws26.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 27)) Then
BL.Range("A1:A100").Copy _
ws27.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 28)) Then
BL.Range("A1:A100").Copy _
ws28.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 29)) Then
BL.Range("A1:A100").Copy _
ws29.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 30)) Then
BL.Range("A1:A100").Copy _
ws30.Range("a1:a100")
End If
If (Date <= DateSerial(Year(Now), Month(Now), 31)) Then
BL.Range("A1:A100").Copy _
ws31.Range("a1:a100")
End If
End Sub
Thank you for your help,
-Azimm