Keep Source Formatting Problem

Willow123

New Member
Joined
Dec 29, 2018
Messages
17
Good Evening All,

So I'm having a problem copying text from one workbook to another and keeping the source formatting. Normally a person can use PasteSpecial or xlpaste:= and this can be accomplished. I think that my code that copies things and then pastes is the problem as it does not allow for the usual syntax? to work. Any thoughts would be greatly appreciated. I would like to keep my code as such (below) if possible.



Rich (BB code):
sh2.Range("G11", sh2.Cells(Rows.Count, "G").End(xlUp)).Copy _
shxx.Cells(Rows.Count, 1).End(xlUp)(1, 9)' tried different variations of paste special or xlpaste:=... here to no avail
sh2.Range("I11", sh2.Cells(Rows.Count, "I").End(xlUp)).Copy _
shxx.Cells(Rows.Count, 1).End(xlUp)(1, 10)
' tried different variations of paste special or xlpaste:=... here to no avail
sh2.Range("I1", sh2.Cells(Rows.Count, "I").End(xlUp)) _ .Replace What:=Chr(10), LookAt:=xlPart, Replacement:=" "



Thanks in advance.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Your original code works for me :confused::confused:
This copies from sh2 and pastes to shxx with source formatting retained
Code:
sh2.Range("G11", sh2.Cells(Rows.Count, "G").End(xlUp)).Copy shxx.Cells(Rows.Count, 1).End(xlUp)(1, 9)

Perhaps I misunderstand what you are trying to do
Here is a method to build what you want
- pasting everything before pasting values and column widths

Code:
    sh2.Range("G11", sh2.Cells(Rows.Count, "G").End(xlUp)).Copy
    With shxx.Cells(Rows.Count, 1).End(xlUp)(1, 9)
        .PasteSpecial (xlPasteAll)
        .PasteSpecial (xlPasteValues)
        .PasteSpecial (xlPasteColumnWidths)
    End With
 
Upvote 0
Thank you for replying Yongle. So, I must clarify a bit. So copy paste does work good but some of the text in the workbook Im copying out of has a Strikethrough font and once that is copied and pasted I have a code to delete it. I can't get it to carry over though and it is just normal looking text. Also, I can't delete in the other Workbook as its a record.
 
Upvote 0
Strikethrough carries through for me :confused:
- which version of Excel are you using?


Strikethrough does not work on forum, so I used underline to illustrate


SAMPLE TEXT (undererline = strikethrough)
"Cell being copied contains this text and the text in red has strikethrough but the text in blue does not"


Amend below to show what the paste text should be and how it should be formatted
"Cell being copied contains this text and the text in red has strikethrough but the text in blue does not"
 
Upvote 0
Is the strikethrough a result of conditional formatting?
 
Upvote 0
Hey sorry guys. Yongle that first bit did work, thank you for that. I had a subroutine manipulating the wrong data and I made it appear not to work.
 
Upvote 0

Forum statistics

Threads
1,224,743
Messages
6,180,687
Members
452,994
Latest member
Janick

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