|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Summing a range using variables
HELP! I'm stuck.
What I'm trying to do, is get my macro to sum a range, the range being defined by variables--it doesn't work. What am I doing wrong? ----------------------------------------- VAR4 = ActiveCell.Offset(0, 5).Address VAR4= ActiveCell.Offset(0, 6).Address SUM = "=sum(VAR4:VAR4)" ActiveCell.Offset(0, 11).Value = SUM ----------------------------------------- Thanks, IG |
|
#2
|
|||
|
|||
|
You seem to have two issues:
1) Your two variables (VAR4) are named the same. I'll assume one should be called VAR4 and teh other VAR5. 2) You entered VAR4 and VAR5 as string text in your SUM variable. VB will not recognize the VAR4 inside double quotes. Try something like: SUM = "=sum(" & VAR4 & ":" & VAR4 & ")" ******************************** If you found this advice useful, please click the weights to add reputation points. Quote:
|
|
#3
|
|||
|
|||
|
Quote:
Agree with mikewbrown, but can be easer to use cells()? Cells(1,11)= Cells(1,6)+Cells(1,5) ![]() |
|
#4
|
|||
|
|||
|
Agreed. I would use cells in this instance too.
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Summing a range using variables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|