PasteSpecial and Offset

  • Thread starter Thread starter Giselle
  • Start date Start date
G

Giselle

greetings

Here is some code from XL help.

With Worksheets("Sheet1")
.Range("C1:C5").Copy
.Range("D1:D5").PasteSpecial _
Operation:=xlPasteSpecialOperationAdd
End With

My code is similar, but I want the PasteSpecial to be offset by 7*CatNum
columns to the right. CatNum is defined earlier in my code as Integer. If
CatNum = 0, then the code should run as shown. If CatNum = 3, then the
PasteSpecial should be offset by 21 columns.

I'm having trouble with the offset syntax.

Much thanks
Giselle
 
Dim rng as Range
With Worksheets("Sheet1")
set rng = .Range("C1:C5")
rng.Copy
rng.offset(0,catnum*7).Pastespecial _
Operation:=xlPasteSpecialOperationAdd
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top