FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,366
- Office Version
- 365
- 2016
- Platform
- Windows
I'm trying to cycle thru some columns, but can't get this array correctly implemented.
It would be easy to use a For loop with a step of say 4, but unfortunately the last column is 5 columns to the right.
Ultimately this is column BL, BP, and BU.
It would be easy to use a For loop with a step of say 4, but unfortunately the last column is 5 columns to the right.
Ultimately this is column BL, BP, and BU.
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Sub AverageCells()[/COLOR][/SIZE][/FONT]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] Dim x As Long[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] Dim c As Range[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] Dim arr() As Variant: arr = Array(64, 68,73)[/FONT][/COLOR][/SIZE]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][/FONT]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] WithActiveSheet[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] For x = LBound(arr) To UBound(arr)[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] For Each c In .Range(.Cells(1, x),.Cells(.Rows.Count, x).End(xlUp))[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] c.Value = c.Value / 12[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] Next c[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] Next x[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Times New Roman] End With[/FONT][/COLOR][/SIZE]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]