kalinkula
kalinkula

Reputation: 3

VBS "PasteSpecial"

I am trying to copy/paste some values from a source XLS to a target XLS. The cells in the target have custom formats, which I need to keep.

I ended up using:

target.Worksheets("Sheet 2").PasteSpecial -4163 -4142, True, False

This does the job of keeping the format, but it doesn't paste the actual value into the target cell, but rather a reference to the source XLS. Can anyone help me and explain, how I can actually paste the value (but still keep the target's format)?

Upvotes: 0

Views: 3871

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200193

Looks to me like you're confusing the Worksheet.PasteSpecial method with the Range.PasteSpecial method.

Try this:

target.Worksheets("Sheet 2").Range("A1").PasteSpecial -4104, -4142, True, False

Upvotes: 2

Related Questions