VBA: Copy and Paste with Text Function

ludlow

Board Regular
Joined
Mar 12, 2013
Messages
87
Here is another one that is puzzling me. I am trying to copy data from worksheet1 to worksheet2. But the difficulty that I am incurring is the use of the Text function - Text(Cells,"#,##0.00").</SPAN>


I need to use the Text function to ensure that all numeric values are printed in Mail Merge to eliminate the dropping of trailing zeroes. Any assistance would be greatly appreciated. Below is a formula I tried to use with no avail.</SPAN>

Code:
WSD.Range("I2:I" & FinalRow).Copy Destination:=WSR.Range.Text(("I2" & LastRow), "#,##0.00")
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Thanks Joe4. I was able to get the data copied to the other spreadsheet with the format needed.

Code:
 WSR.Range("I2:I" & LastRow) = "=Text(DataDrop!I2,""#,##0.00"")"
 
Upvote 0
After more texting, it became apparent that the above code will not work as intended. However, with the suggestion of Joe4, I found something that will work

Code:
Sub hmm()
    Dim WSR As Worksheet
    Set WSR = Worksheets("CustRecords")
    FinalRow = WSR.Cells(Rows.Count, 1).End(xlUp).Row
    Set c = WSR.Range("J2:V" & FinalRow)
    c.NumberFormat = "#,##0.00;(#,##0.00)"
End Sub
For more info: Range.Text Property (Excel)
 
Upvote 0

Forum statistics

Threads
1,225,073
Messages
6,182,706
Members
453,132
Latest member
nsnodgrass73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top