Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
My code is below. It keeps throwing an error on the fist for each.
It says Next without for. Any help will be greatly appreciated. Thanks, Jay Sub SumHKCdays() Dim DataSht As Worksheet Dim Start As Double Dim LstRow As Long Dim RngHD As Range Dim RngKD As Range Dim RngCD As Range Dim Rng As Range Dim i Dim Dt As Double Dim X As Double Dim Target As Range Set Target = Range("H3") Set DataSht = Sheet22 LstRow = DataSht.Range("A1").SpecialCells(xlCellTypeLastCel l).Row Set RngHD = DataSht.Range("A5:A" & LstRow) Set RngKD = DataSht.Range("BC5:BC" & LstRow) Set RngCD = DataSht.Range("CD5:CD" & LstRow) Do Until Target.Roww = 32 If Target.Offset(0, -7) = "" Then i = 0 Else Start = Target.Offset(0, -7) - 13 Dt = Target.Offset(0, -7) For Each i In RngHD If i <= Dt And i = Start Then X = X + i.Offset(0, 1) + i.Offset(0, 6) + i.Offset(0, 11) + _ i.Offset(0, 16) + i.Offset(0, 21) + i.Offset(0, 26) + _ i.Offset(0, 31) + i.Offset(0, 36) + i.Offset(0, 43) + i.Offset(0, 48) Else X = X + 0 End Next i For Each i In RngKD If i <= Dt And i = Start Then X = X + i.Offset(0, 1) + i.Offset(0, 6) + i.Offset(0, 11) + _ i.Offset(0, 16) + i.Offset(0, 21) + i.Offset(0, 24) Else X = X + 0 End Next i For Each i In RngCD If i <= Dt And i = Start Then X = X + i.Offset(0, 1) + i.Offset(0, 4) + i.Offset(0, 7) + _ i.Offset(0, 12) Else X = X + 0 End Next i End If i = X Loop End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I need a macro to transpose multiple columns A1-Z1, A2-X2 etc | Excel Discussion (Misc queries) | |||
Combine multiple columns into two long columns, Repeating rows in first column | Excel Discussion (Misc queries) | |||
Combine multiple columns into two long columns, Repeating rows in first column | Excel Discussion (Misc queries) | |||
macro to compile columns on multiple sheets | Excel Discussion (Misc queries) | |||
Macro to align and compare multiple rows and columns | New Users to Excel |