L
Lvenom
With alot of reading, I have been able to piece together some code t
auto sum a variable length column. My column data is coming from
filtered column on a separate worksheet. My problem is, the code stop
when the filtered column from the other sheet has no data present
(Data is filtered off of date entries and sometimes there is no dat
for a specific date). How do I stop the code if there is no data t
sum? Here is the macro:
Sub totalcolumn()
'To position the cursor in the "AutoSum" cell
Range("Q2").End(xlDown).Offset(1, 0).Select
'Determine the Row numbers
vRowTop = 2
vRowBottom = ActiveCell.Offset(-1, 0).Row
'Compute the R[ ] variable
vDiff = vRowBottom - vRowTop + 1
'Enter the formulas
Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
'Move the cursor one cell to the right
Selection.Offset(0, 1).Select
'To enter the =Sum formula in the second column of data
Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
Columns("Q:R").Select
End Su
auto sum a variable length column. My column data is coming from
filtered column on a separate worksheet. My problem is, the code stop
when the filtered column from the other sheet has no data present
(Data is filtered off of date entries and sometimes there is no dat
for a specific date). How do I stop the code if there is no data t
sum? Here is the macro:
Sub totalcolumn()
'To position the cursor in the "AutoSum" cell
Range("Q2").End(xlDown).Offset(1, 0).Select
'Determine the Row numbers
vRowTop = 2
vRowBottom = ActiveCell.Offset(-1, 0).Row
'Compute the R[ ] variable
vDiff = vRowBottom - vRowTop + 1
'Enter the formulas
Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
'Move the cursor one cell to the right
Selection.Offset(0, 1).Select
'To enter the =Sum formula in the second column of data
Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
Columns("Q:R").Select
End Su