0

Good evening friends. I have a really stupid request to which I can't find the correct solution. I need to insert, in the procedure that you can see below, the ".PasteSpecial xlPasteValues" parameter in the correct way, to have only values to be pasted in the destination workbook. The below procedure works fine and I would not change it if possible, but integrate it with the parameter mentioned above. Unless I change the code and use other solutions. I repeat, the code below is now tested and I use it safely, but now the need to paste the cell format and validations of the original workbook is no longer needed.

Thanks for any suggestions.

Edit:

I'll try to be clearer. I know there are similar requests already resolved. My question is where to put the ".PasteSpecial xlPasteValues" parameter correctly in the procedure that I use already. The other solutions do not paste data into a table, while I use a source and destination table.

Public Sub CopyOnMasterDB ()

Dim CopyFrom As Range
Dim Copyto As Range

Set CopyFrom = Workbooks ("FromFile.xlsm"). Worksheets ("Database"). UsedRange.Offset (2, 0)
Set Copyto = Workbooks ("MASTER_DATABASE.xlsx"). Worksheets (1) .Range ("A" & Rows.count) .End (xlUp) .Offset (1, 0) 'Error If I insert .PasteSpecial xlPasteValues

CopyFrom .Copy Destination: = Copyto 'Error If I insert .PasteSpecial xlPasteValues
Application.CutCopyMode = False

Workbooks ("MASTER_DATABASE.xlsx"). Close SaveChanges: = True

End Sub
Ilio
  • 1
  • 2

1 Answers1

1

Change:

CopyFrom.Copy Destination:=CopyTo

to

CopyFrom.Copy
CopyTo.PasteSpecial xlPasteValues
BigBen
  • 46,229
  • 7
  • 24
  • 40
  • BigBen! Simple, fast. The solution I was looking for. In fact I said that my request was "stupid" but that it made me stop. Thanks BigBen! – Ilio Apr 27 '19 at 23:09
  • BigBen, I believe there is a misunderstanding. I edited my request to be clearer. Finally, I voted for your solution. I did not repeat the request. At least I think so. If I made a mistake I apologize but it was not my intention. – Ilio Apr 27 '19 at 23:49
  • It's `Range.PasteSpecial`. If you're going to paste special you need one line to copy, and a second line to paste. – BigBen Apr 28 '19 at 04:21