D
darno
My query needs an extension to the following Macro:
Sub AAtester10()
Dim sStart As String, sEnd As String
Dim res As Variant, res1 As Variant
Dim rng As Range
Dim cng As Range
sStart = InputBox("Enter Start Date")
sEnd = InputBox("Enter End Date")
If IsDate(sStart) And IsDate(sEnd) Then
res = Application.Match(CLng(CDate(sStart)), Range("B1:B800"), 0)
res1 = Application.Match(CLng(CDate(sEnd)), Range("B1:B800"), 0)
If Not IsError(res) And Not IsError(res1) Then
Set rng = Range(Range("B1:B800")(res), Range("B1:B800")(res1))
rng.Resize(, 31).BorderAround Weight:=xlMedium, ColorIndex:=3
Set rng = rng(1, 1).Offset(0, -1).Resize(rng.Count)
rng(1, 1).FormulaR1C1 = "=R[-1]C+1"
rng(1, 1).AutoFill rng
rng.Copy
rng.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
End If
End Sub
In this Macro what further I look for is a formula that can be copie
into any range dependent column. As this macro uses rng and do an aut
count in Column A before date column B.
what I am looking for is a piece of code that could fill up a su
formula in column E. Lets say if the first input had a date which wa
in column B cell B2 (12-may-2003) and the second input had a date tha
was in same column B but in cell B30 . in this case what I need is t
copy a formula in column E (from E1 to E29), it could be any range a
it is dependent on inputs. The formula should do a sum of column
values, column G contains only 1 in each row .so from D1 to D800 ther
are just 1s (Ones) only, what I need this sum formula to calculat
values with an increment in row. For example the value in D1 was
(one) so the formula in E1 should show 1 as result and if the value i
D2 was 1 again the formula in E2 should show 2 and if the value in D
was 1 again then E3 should show 3 and if the value in D4 was 0 (zero
then E4 should show 3 as a result it will keep on going until the eac
column cell is not filled with result.
Column A Column B ColumnC Column D Column E
1 12-may-03 r 1 SUM(D1)
2 13-may-03 r 1 SUM(D12)
3 14-may-03 r 1 SUM(D13)
Regards,
Darn
Sub AAtester10()
Dim sStart As String, sEnd As String
Dim res As Variant, res1 As Variant
Dim rng As Range
Dim cng As Range
sStart = InputBox("Enter Start Date")
sEnd = InputBox("Enter End Date")
If IsDate(sStart) And IsDate(sEnd) Then
res = Application.Match(CLng(CDate(sStart)), Range("B1:B800"), 0)
res1 = Application.Match(CLng(CDate(sEnd)), Range("B1:B800"), 0)
If Not IsError(res) And Not IsError(res1) Then
Set rng = Range(Range("B1:B800")(res), Range("B1:B800")(res1))
rng.Resize(, 31).BorderAround Weight:=xlMedium, ColorIndex:=3
Set rng = rng(1, 1).Offset(0, -1).Resize(rng.Count)
rng(1, 1).FormulaR1C1 = "=R[-1]C+1"
rng(1, 1).AutoFill rng
rng.Copy
rng.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
End If
End Sub
In this Macro what further I look for is a formula that can be copie
into any range dependent column. As this macro uses rng and do an aut
count in Column A before date column B.
what I am looking for is a piece of code that could fill up a su
formula in column E. Lets say if the first input had a date which wa
in column B cell B2 (12-may-2003) and the second input had a date tha
was in same column B but in cell B30 . in this case what I need is t
copy a formula in column E (from E1 to E29), it could be any range a
it is dependent on inputs. The formula should do a sum of column
values, column G contains only 1 in each row .so from D1 to D800 ther
are just 1s (Ones) only, what I need this sum formula to calculat
values with an increment in row. For example the value in D1 was
(one) so the formula in E1 should show 1 as result and if the value i
D2 was 1 again the formula in E2 should show 2 and if the value in D
was 1 again then E3 should show 3 and if the value in D4 was 0 (zero
then E4 should show 3 as a result it will keep on going until the eac
column cell is not filled with result.
Column A Column B ColumnC Column D Column E
1 12-may-03 r 1 SUM(D1)
2 13-may-03 r 1 SUM(D12)
3 14-may-03 r 1 SUM(D13)
Regards,
Darn