upobDaPlaya
asked on
Adding a range in Excel
What is the recommended way in adding a range in MS Excel VBA...When I search the Internet some suggest the below ? Also if I wanted to sum a range, but I have the column number not the latter are there any suggestions for using the column number ?
Range("A1").Formula ="=Sum(A2:B3)"
Range("A1").Formula ="=Sum(A2:B3)"
ASKER
I have the below information
Start row End Row
10 50
60 70
250 500
For each of the start and end points I want to sum columns A-Z. Thus, I want to sum
A10:A50 in A51
A60:A70 in A71
A250:A500 in A501
b10:b50 in b51
b60:A70 in b71
b250:b500 in b501
etc..
My problem is I do not want to write out a line of code for each column start and end points. I was hoping I could loop thru the column numbers to do the calculation as I know I always need to add columns A to Z (can you do a loop on letters a-z ?) Note the start and end points are already stored in a worksheet which I dynamically create each time I run the code.
Start row End Row
10 50
60 70
250 500
For each of the start and end points I want to sum columns A-Z. Thus, I want to sum
A10:A50 in A51
A60:A70 in A71
A250:A500 in A501
b10:b50 in b51
b60:A70 in b71
b250:b500 in b501
etc..
My problem is I do not want to write out a line of code for each column start and end points. I was hoping I could loop thru the column numbers to do the calculation as I know I always need to add columns A to Z (can you do a loop on letters a-z ?) Note the start and end points are already stored in a worksheet which I dynamically create each time I run the code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Never had used resize before..thanks for the tip..
Kevin