ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   concatenate text and formatted cell (https://www.excelbanter.com/excel-programming/409187-concatenate-text-formatted-cell.html)

Reddy

concatenate text and formatted cell
 
Hello
I'm trying to concatenate some text and the numeric value of a cell
formatted to 2 decimal places and enter the result in a cell -
VarPasteCell.
Using the following vba code in excel,

VarPasteCell.Value = "DP:£" & Cell.Offset(0, 5).Value

I get the result DP:£6.8 but am looking for DP:£6.80 as the number is
a price.

Is there a way to format the number in the same line of code? I've
tried using application.round(cell.offset(0,5).value, 2) and various
other custom formatting techniques but can't get it to work.

Please can you help?
Thanks in advance

Mike H

concatenate text and formatted cell
 
maybe

Range("VarPasteCell").Value = "DP:£" & Range("VarPasteCell").Offset(0, 5).Text

Mike

"Reddy" wrote:

Hello
I'm trying to concatenate some text and the numeric value of a cell
formatted to 2 decimal places and enter the result in a cell -
VarPasteCell.
Using the following vba code in excel,

VarPasteCell.Value = "DP:£" & Cell.Offset(0, 5).Value

I get the result DP:£6.8 but am looking for DP:£6.80 as the number is
a price.

Is there a way to format the number in the same line of code? I've
tried using application.round(cell.offset(0,5).value, 2) and various
other custom formatting techniques but can't get it to work.

Please can you help?
Thanks in advance


Reddy

concatenate text and formatted cell
 
On Apr 11, 12:51*pm, Mike H wrote:
maybe

Range("VarPasteCell").Value = "DP:£" & Range("VarPasteCell").Offset(0, 5).Text

Mike

Excellent!
Replacing .Value with .Text works a treat.
Thanks v much
R



All times are GMT +1. The time now is 07:32 PM.

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