Dynamic Colums and Summing
Posted by Brian S. on December 20, 2001 1:09 PM
Below is some code that I use to loop through columns deleting those that are empty. Now what I would like to do is that on the end column, select that column and Sum by Row(using sum(k2:(whatever last column is)2.)
The problem is that this will be dynamic and I don't know how to tell excel to use this column in the code.
Dim var1, var2, var3 As String
Dim count As Integer
var1 = "K"
Do While var1 <= "Z"
var2 = "4"
var3 = var1 & var2
Do While Sheets("qryOut").Range("" & var3 & "").Value = ""
If count >= 100 Then
Columns(var1 & ":" & var1).Select
Application.CutCopyMode = False
count = count + 1
Z = Asc(var1) 'To modify for Z to be a add (64=A, 96=a)
If Z >= 123 Then
var1 = Chr(Z + 1)
*Should be on empty column ready for sums*