ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Formula - Macro (https://www.excelbanter.com/excel-discussion-misc-queries/168570-formula-macro.html)

orquidea

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

CLR

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


orquidea

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


CLR

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


Dave Peterson

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

CLR

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


orquidea

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


orquidea

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



All times are GMT +1. The time now is 08:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com