Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 5th, 2005, 01:57 PM
iceguy iceguy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 1 iceguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 26 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old August 5th, 2005, 06:41 PM
mikewbrown mikewbrown is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Vancouver, BC
Posts: 12 mikewbrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 57 m 53 sec
Reputation Power: 0
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:
Originally Posted by iceguy
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

Reply With Quote
  #3  
Old August 8th, 2005, 09:11 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 5
Quote:
VAR4 = ActiveCell.Offset(0, 5).Address
VAR4= ActiveCell.Offset(0, 6).Address

SUM = "=sum(VAR4:VAR4)"

ActiveCell.Offset(0, 11).Value = SUM


Agree with mikewbrown, but can be easer to use cells()?

Cells(1,11)= Cells(1,6)+Cells(1,5)

Reply With Quote
  #4  
Old August 8th, 2005, 11:59 AM
mikewbrown mikewbrown is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Vancouver, BC
Posts: 12 mikewbrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 57 m 53 sec
Reputation Power: 0
Agreed. I would use cells in this instance too.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Summing a range using variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT