Anthony's VBA Forum Index Anthony's VBA Forum
Where the knowledge is shared
Menu
 Anthony's VBA Forum IndexHome Page
 Anthony's VBA Forum IndexForum Index
FAQFAQ
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesMessages
Log inLogin/Out

Quick Search

Advanced Search

Links
Consulting
Products

Who's Online
[ Administrator ]
[ Moderator ]


how to use functions in macros

 
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA
View previous topic :: View next topic  
Author Message
vin_vba



Joined: 03 Jun 2005
Posts: 1

PostPosted: Mon Jun 06, 2005 1:02 am    Post subject: how to use functions in macros Reply with quote

Hello,

I am new comer to excel macros. Could someone help me in the following.

I have data data in the range a1:c10 and i want to find the sum of a1:a10, b1:b10 and c1:c10 in the cells a11, b11 and c11.

I have written the following macro.

***********************************
Sub row_col_tot()
Dim rang1, rang2 As String

Application.Goto Reference:=Range("a1")

rang1 = ActiveCell.Address
MsgBox rang1

Range("a1").End(xlDown).Select
rang2 = ActiveCell.Address
MsgBox rang2

ActiveCell.Offset(1, 0).Range("a1").Select
ActiveCell.Formula = "=sum(rang1:rang2)"
'ActiveCell.Value = "=sum()"

End Sub

***********************************

Here i get the $a$1 in rang1 and $a$10 rang2. But the "=sum(rang1:rang2)" is not working. How can i make the sum function work here??

Looking forward to hear from you.

Regards

Vinayan K P
Back to top
View user's profile Send private message Send e-mail
Data
Moderator
Moderator


Joined: 06 Oct 2004
Posts: 33
Location: NY

PostPosted: Wed Jun 08, 2005 10:09 pm    Post subject: Reply with quote

Try

ActiveCell.Formula = "=sum(" & rang1 & ":" & "rang2" & ")" Dancing Dog
_________________
Data
Knowledge is Power
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Jun 09, 2005 12:00 am    Post subject: thanks a lot.glad there are people like u to help new ones Reply with quote

Dear Data,

Thank u very much for your reply to my question and it worked

ActiveCell.Formula = "=sum(" & rang1 & ":" & "rang2" & ")"

though i had to make your typing error...

ActiveCell.Formula = "=sum(" & rang1 & ":" & rang2 & ")"


Its wonderful to have a form like this and a person like you there to help someone like me, who are new comers to macro and vb. just too good.

Last few days i was trying for a option as i want to input values to certain variables through keyboard interatively while the macro is running. the values could be integers, range, functions etc..... can you help me??

Regards

Vinayan
Back to top
Data
Moderator
Moderator


Joined: 06 Oct 2004
Posts: 33
Location: NY

PostPosted: Tue Jun 21, 2005 10:33 am    Post subject: Reply with quote

Sure Vinayan. I will see what I can do to help.
_________________
Data
Knowledge is Power
Back to top
View user's profile Send private message
stano
Guest





PostPosted: Fri Jul 14, 2006 10:12 am    Post subject: thanks Reply with quote

thank it help me too!!!!!
Back to top
Display posts from previous:   
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group