[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Concatenate Text in Visual Basic

daniroy

12/15/2006 3:28:00 PM

Hello there,
I need to aggregate two text as "EUR" and "GBP" to create a third text
as "EURGBP".
Here is the code I am using now. CurrencyCode = "Currency1Currency2" in
Locals window, in place of "EURGBP". Any ideas? Kind regards to
everybody, Daniel

Sub Convert_Figures()

Dim Currency1 As Variant
Dim Currency2 As Variant
Dim CurrencyCode As Variant

For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1
Currency1 = Sheets("Characteristics").Range("G" & i)
Currency2 = Sheets("Characteristics").Range("H" & i)
CurrencyCode = "Currency1" & "Currency2"

Next i

End Sub

4 Answers

Dave Miller

12/15/2006 3:57:00 PM

0

If you want the variables to concatenate, you need to take the Quotes
away from them. The quote marks them a string:

like this:

CurrencyCode = Currency1 & Currency2


David Miller


daniroy@gmail.com wrote:
> Hello there,
> I need to aggregate two text as "EUR" and "GBP" to create a third text
> as "EURGBP".
> Here is the code I am using now. CurrencyCode = "Currency1Currency2" in
> Locals window, in place of "EURGBP". Any ideas? Kind regards to
> everybody, Daniel
>
> Sub Convert_Figures()
>
> Dim Currency1 As Variant
> Dim Currency2 As Variant
> Dim CurrencyCode As Variant
>
> For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1
> Currency1 = Sheets("Characteristics").Range("G" & i)
> Currency2 = Sheets("Characteristics").Range("H" & i)
> CurrencyCode = "Currency1" & "Currency2"
>
> Next i
>
> End Sub

Dave Miller

12/15/2006 3:58:00 PM

0

If you want the variables to concatenate, you need to take the Quotes
away from them. The quote marks make them strings:

like this:

CurrencyCode = Currency1 & Currency2


David Miller


daniroy@gmail.com wrote:
> Hello there,
> I need to aggregate two text as "EUR" and "GBP" to create a third text
> as "EURGBP".
> Here is the code I am using now. CurrencyCode = "Currency1Currency2" in
> Locals window, in place of "EURGBP". Any ideas? Kind regards to
> everybody, Daniel
>
> Sub Convert_Figures()
>
> Dim Currency1 As Variant
> Dim Currency2 As Variant
> Dim CurrencyCode As Variant
>
> For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1
> Currency1 = Sheets("Characteristics").Range("G" & i)
> Currency2 = Sheets("Characteristics").Range("H" & i)
> CurrencyCode = "Currency1" & "Currency2"
>
> Next i
>
> End Sub

daniroy

12/15/2006 5:14:00 PM

0

found it, sorry to bother you with things I found solution a minute
after I post it

Sub Get_Currency_Code()

Dim Currency1 As Variant
Dim Currency2 As Variant
Dim CurrencyCode As Variant

For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1
Currency1 = Sheets("Characteristics").Range("G" & i)
Currency2 = Sheets("Characteristics").Range("H" & i)
CurrencyCode = Currency1 & Currency2

Next i

End Sub

On Dec 15, 3:28 pm, dani...@gmail.com wrote:
> Hello there,
> I need to aggregate two text as "EUR" and "GBP" to create a third text
> as "EURGBP".
> Here is the code I am using now. CurrencyCode = "Currency1Currency2" in
> Locals window, in place of "EURGBP". Any ideas? Kind regards to
> everybody, Daniel
>
> Sub Convert_Figures()
>
> Dim Currency1 As Variant
> Dim Currency2 As Variant
> Dim CurrencyCode As Variant
>
> For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1
> Currency1 = Sheets("Characteristics").Range("G" & i)
> Currency2 = Sheets("Characteristics").Range("H" & i)
> CurrencyCode = "Currency1" & "Currency2"
>
> Next i
>
> End Sub

daniroy

12/15/2006 5:17:00 PM

0

found it, sorry to bother you with things I found solution a minute
after I post it

Sub Get_Currency_Code()

Dim Currency1 As Variant
Dim Currency2 As Variant
Dim CurrencyCode As Variant

For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1
Currency1 = Sheets("Characteristics").Range("G" & i)
Currency2 = Sheets("Characteristics").Range("H" & i)
CurrencyCode = Currency1 & Currency2

Next i

End Sub

On Dec 15, 3:28 pm, dani...@gmail.com wrote:
> Hello there,
> I need to aggregate two text as "EUR" and "GBP" to create a third text
> as "EURGBP".
> Here is the code I am using now. CurrencyCode = "Currency1Currency2" in
> Locals window, in place of "EURGBP". Any ideas? Kind regards to
> everybody, Daniel
>
> Sub Convert_Figures()
>
> Dim Currency1 As Variant
> Dim Currency2 As Variant
> Dim CurrencyCode As Variant
>
> For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1
> Currency1 = Sheets("Characteristics").Range("G" & i)
> Currency2 = Sheets("Characteristics").Range("H" & i)
> CurrencyCode = "Currency1" & "Currency2"
>
> Next i
>
> End Sub