-
Notifications
You must be signed in to change notification settings - Fork 0
/
NextDateArray.vbs
53 lines (43 loc) · 1.29 KB
/
NextDateArray.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Sub NextDateArray()
'For this macro, I had hourly data that I was trying to combine into days. I could not get Excel's autofill to work as I wanted, so I wrote this little macro instead.
'Set the active sheet as a variable for easier reference
Dim ws As Worksheet
Set ws = ActiveSheet
Dim cell As Range
Dim O As Long
Dim P As Long
Dim X As Long
Dim NewFormula As String
'Find lastRow'
lastRow = ws.Cells(ws.Rows.Count, 17).End(xlUp).Row
O = 25
P = 48
'Add 24 to both cell addresses'
For i = 11 To lastRow
Set cell = ws.Cells(i, 19)
cell.Value = "=MAX(O" & O & ":P" & P & ")"
O = O + 24
P = P + 24
Next i
End Sub
Sub NextNextDateArray()
'Set the active sheet as a variable for easier reference
Dim ws As Worksheet
Set ws = ActiveSheet
Dim cell As Range
Dim O As Long
Dim P As Long
Dim X As Long
Dim NewFormula As String
'Find lastRow'
lastRow = ws.Cells(ws.Rows.Count, 17).End(xlUp).Row
O = 25
P = 48
'Add 24 to both cell addresses'
For i = 11 To lastRow
Set cell = ws.Cells(i, 22)
cell.Value = "=MAX(O" & O & ":O" & P & ")"
O = O + 24
P = P + 24
Next i
End Sub