#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Formula - Macro

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea
  #2   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Formula - Macro

Try this.........

Range("A1").Value = "=concatenate(SUM(B2:B4) & "" - 20 's"")"

Vaya con Dios,
Chuck, CABGx3



"orquidea" wrote:

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Formula - Macro

Thanks for your answer.

I still need the variable ATLN40 = (the total of the sum) bacause I will
use the result of this variable for other calculation, so I will need to
refer to ATLN40.

Usted tambien vaya con Dios

"CLR" wrote:

Try this.........

Range("A1").Value = "=concatenate(SUM(B2:B4) & "" - 20 's"")"

Vaya con Dios,
Chuck, CABGx3



"orquidea" wrote:

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea

  #4   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Formula - Macro

If you don't get anything any better, this will work for a small range...

atln40 = Range("b2").Value + Range("b3").Value + Range("b4").Value

or you can compute the sum on the sheet in a helper cell and then refer to
that cell for the total

Vaya con Dios,
Chuck, CABGx3



"orquidea" wrote:

Thanks for your answer.

I still need the variable ATLN40 = (the total of the sum) bacause I will
use the result of this variable for other calculation, so I will need to
refer to ATLN40.

Usted tambien vaya con Dios

"CLR" wrote:

Try this.........

Range("A1").Value = "=concatenate(SUM(B2:B4) & "" - 20 's"")"

Vaya con Dios,
Chuck, CABGx3



"orquidea" wrote:

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Formula - Macro

Maybe...

Dim ATLN40 as double
ATLN40 = application.sum(worksheets("somesheetname").range( "b2:b4"))

worksheets("somesheetname").range("a1").value = ATLN40 & " - 20's"
or
worksheets("somesheetname").range("a1").value _
= format(ATLN40, "0.000") & " - 20's"

=======
Or maybe if you want A1 to be a formula:

with worksheets("somesheetname")
.Range("a1").formula = "=SUM(B2:B4)&"" - 20's"""
end with

or maybe...

.Range("a1").formula = "=text(SUM(B2:B4),""0.000"")&"" - 20's"""

Depending on how you want it formatted.

orquidea wrote:

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Formula - Macro

Some lines from Dave's suggestions, and one from your original, seems to get
it....

Sub ConcatRangeSum()
Dim ATLN40 As Double
ATLN40 = Application.Sum(Worksheets("Sheet1").Range("b2:b4" ).Value)
'MsgBox ATLN40
Range("a1").Value = ATLN40 & " - 20 's"
End Sub

Vaya con Dios,
Chuck, CABGx3


"orquidea" wrote:

Thanks for your answer.

I still need the variable ATLN40 = (the total of the sum) bacause I will
use the result of this variable for other calculation, so I will need to
refer to ATLN40.

Usted tambien vaya con Dios

"CLR" wrote:

Try this.........

Range("A1").Value = "=concatenate(SUM(B2:B4) & "" - 20 's"")"

Vaya con Dios,
Chuck, CABGx3



"orquidea" wrote:

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Formula - Macro

Thanks Dave for your help

"Dave Peterson" wrote:

Maybe...

Dim ATLN40 as double
ATLN40 = application.sum(worksheets("somesheetname").range( "b2:b4"))

worksheets("somesheetname").range("a1").value = ATLN40 & " - 20's"
or
worksheets("somesheetname").range("a1").value _
= format(ATLN40, "0.000") & " - 20's"

=======
Or maybe if you want A1 to be a formula:

with worksheets("somesheetname")
.Range("a1").formula = "=SUM(B2:B4)&"" - 20's"""
end with

or maybe...

.Range("a1").formula = "=text(SUM(B2:B4),""0.000"")&"" - 20's"""

Depending on how you want it formatted.

orquidea wrote:

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Formula - Macro

Thanks for your help

"CLR" wrote:

If you don't get anything any better, this will work for a small range...

atln40 = Range("b2").Value + Range("b3").Value + Range("b4").Value

or you can compute the sum on the sheet in a helper cell and then refer to
that cell for the total

Vaya con Dios,
Chuck, CABGx3



"orquidea" wrote:

Thanks for your answer.

I still need the variable ATLN40 = (the total of the sum) bacause I will
use the result of this variable for other calculation, so I will need to
refer to ATLN40.

Usted tambien vaya con Dios

"CLR" wrote:

Try this.........

Range("A1").Value = "=concatenate(SUM(B2:B4) & "" - 20 's"")"

Vaya con Dios,
Chuck, CABGx3



"orquidea" wrote:

Hi

How do I have to code the below procedure in a macro properly?

ATLN40 = "=Sum(B2:B4)"

I want to diplay the result in other cell. I have the following code:
Range("A1").Value= ATLN40 & " - 20's"
What I am getting now in Range A1 is =Sum(B2:B4) - 20's , not the
result of the sum.

Could anyone help me please?

Thanks,
Orquidea

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula or Macro M Hebert Excel Discussion (Misc queries) 2 June 27th 07 01:24 PM
Is there a Formula or Macro for This? Marilyn Excel Discussion (Misc queries) 8 May 7th 07 05:03 PM
Macro Formula for Max value John Bundy Excel Worksheet Functions 0 November 30th 06 05:25 PM
Macro Formula for Max value Gary''s Student Excel Worksheet Functions 0 November 30th 06 05:20 PM
Add formula to Macro??? [email protected] New Users to Excel 3 July 9th 06 02:29 PM


All times are GMT +1. The time now is 04:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"