Shehroz Malik
Shehroz Malik

Reputation: 43

How to copy paste, receiving error for VBA

I am trying to copy a cell from a worksheet represented by "a" into the current sheet through this code. In the current sheet, I chose a reference point and then go to the last column, and then do an offset into a new column to paste.

This line is EXACTLY like another code I have in my larger code, not sure why its not working and giving a Run Time error

Anybody have thoughts?

Code that works:

Range("b15").End(xlToRight).Copy Range("B15").End(xlToRight).Offset(0, 1)

Code that does not work:

a.Range("D24").Copy Range("A4").End(x1ToRight).Offset(0, 1)

Run time or user defined error

Upvotes: 0

Views: 27

Answers (2)

Simon
Simon

Reputation: 69

It looks like you used 1 instead of l in the second snippet of code. Change it to the letter,

a.Range("D24").Copy Range("A4").End(xlToRight).Offset(0, 1)

Upvotes: 0

Mikku
Mikku

Reputation: 6664

You are using x1 One, It should be L

Try this:

a.Range("D24").Copy Range("A4").End(xlToRight).Offset(0, 1)

Also, I would suggest you to use a Sheet reference for Destination in above line.

Upvotes: 1

Related Questions