.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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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
Have you tried using text property instead of value?

Code:
    TagName = .Cells(41, CustCol).Text 'Tag Name
    TagValue = .Cells(CustRow, CustCol).Text 'Tag Value

that's done the trick. thank you for the quick response :)
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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