Paste but keep Destination formatting

zgivod

New Member
Joined
Dec 6, 2018
Messages
17
hi heres my code but its keeping the sheet 1 text format when i want it to be like sheet 2 text and cell format


Private Sub CommandButton1_Click()
Sheets("sheet1").Range("A1:A4").SpecialCells(xlConstants).copy _
Sheets("sheet2").Range("A1:A4").End(xlUp)
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Not knowing why you are using SpecialCells(xlConstants) as you haven't stated it then try (it is also unusual to use End(xlUp) with such a small range)...

Code:
Private Sub CommandButton1_Click()
    With Sheets("sheet1").Range("A1:A4")
        Sheets("sheet2").Range("A1:A4").End(xlUp).Value = .SpecialCells(xlConstants).Value
    End With
End Sub

or

Code:
Private Sub CommandButton1_Click()
    With Sheets("sheet1").Range("A1:A4")
        Sheets("sheet2").Range("A1:A4").End(xlUp).Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With
End Sub

You might need to provide more details.
 
Upvote 0
If you just pastespeciel the values, if should not impact the formatting.

Or you can just make one range value equal another range value
Code:
Sheets("Sheet2").Range("A1:A4").Value = Sheets("Sheet1").Range("A1:A4").Value
 
Upvote 0
the small range was just to test the code. im trying to get all the text on a range with no blanks sent to sheet2 where it will keep the sheet 2 format
 
Upvote 0
If your values are constants and not from formulas why can't you just do ....
Code:
    Sheets("sheet1").Range("A1:A4").SpecialCells(xlCellTypeConstants, 23).Copy
    Sheets("sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
 
Last edited:
Upvote 0
If your values are constants and not from formulas why can't you just do ....
Code:
    Sheets("sheet1").Range("A1:A4").SpecialCells(xlCellTypeConstants, 23).Copy
    Sheets("sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False

because only A1 is getting changed to the sheet2 format all other ones are keeping sheet1 format
 
Upvote 0
because only A1 is getting changed to the sheet2 format all other ones are keeping sheet1 format

Pardon, how does pasting as xlValues change any of the the Sheet2 formats?... not possible that I have ever seen!

Have you actually ran the code as posted?
If you have and that is the result you get please upload your workbook to www.box.com, mark it for sharing and post the link it provides in the thread please so we can look at it.


...and can you confirm you want to retain the Sheet2 format.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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