 |
Anthony's VBA Forum Where the knowledge is shared |
|
|
View previous topic :: View next topic |
Author |
Message |
vin_vba
Joined: 03 Jun 2005 Posts: 1
|
Posted: Mon Jun 06, 2005 1:02 am Post subject: how to use functions in macros |
|
|
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 |
|
 |
Data Moderator


Joined: 06 Oct 2004 Posts: 33 Location: NY
|
Posted: Wed Jun 08, 2005 10:09 pm Post subject: |
|
|
Try
ActiveCell.Formula = "=sum(" & rang1 & ":" & "rang2" & ")"  _________________ Data
Knowledge is Power |
|
Back to top |
|
 |
Guest
|
Posted: Thu Jun 09, 2005 12:00 am Post subject: thanks a lot.glad there are people like u to help new ones |
|
|
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


Joined: 06 Oct 2004 Posts: 33 Location: NY
|
Posted: Tue Jun 21, 2005 10:33 am Post subject: |
|
|
Sure Vinayan. I will see what I can do to help. _________________ Data
Knowledge is Power |
|
Back to top |
|
 |
stano Guest
|
Posted: Fri Jul 14, 2006 10:12 am Post subject: thanks |
|
|
thank it help me too!!!!! |
|
Back to top |
|
 |
|
|
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
|