.contect.find not keeping the format

owen4512

Board Regular
Joined
Dec 10, 2014
Messages
71
Hi all,

I have created the below loop and find and replaces instances in word. I have created an excel spread sheet and some of the data that's being replaced is currently formatted as currency in excel. The find and replace feature works perfectly and replaces everything correctly. The only issue is the data that's formatted as currency in excel is not formatted the same in word.

Would it be possible to carry to format over into word?

Thanks in advance.

Code:
                                      For CustCol = 2 To 39 'Move Through Columns
                                            TagName = .Cells(41, CustCol).Value 'Tag Name
                                            TagValue = .Cells(CustRow, CustCol).Value 'Tag Value
                                             With WordDoc.Content.Find
                                                .Text = TagName
                                                .Replacement.Text = TagValue
                                                .Wrap = wdFindContinue
                                                .Execute Replace:=wdReplaceAll 'Find & Replace all instances
                                             End With
                                        Next CustCol
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Have you tried using text property instead of value?

Code:
    TagName = .Cells(41, CustCol).Text 'Tag Name
    TagValue = .Cells(CustRow, CustCol).Text 'Tag Value
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,972
Members
452,540
Latest member
haasro02

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