Using Range Object With Two Variables

G

Guest

I get an error when I try & pass the range object two variables. I have
tested this & it allows the use of one varaible. But I would like to use two
variables to copy & paste cell A8:D8. Is there something wrong with my syntax
or will I need to copy & paste one row at a time?


Dim UserName_Addr As String ' Where UserName_Addr = A8
Dim Resp_Addr As String ' Where Resp_Addr = D8

'Copy columns A,B,C, and D from Sheet 1 to Sheet 2
With Sheets("Sheet1")
.Range(.Range("UserName_Addr: Resp_Addr"),
..Range("A65536").End(xlUp)).Copy
End With
Sheets("Sheet2").[A65536].End(xlUp)(1).PasteSpecial Paste:=xlValues


Thx!
ALATL
 
N

Norman Jones

Hi Alatl,

Try replacing:
Range("UserName_Addr: Resp_Addr")

with

Range("UserName_Addr & ":" & Resp_Addr")


---
Regards,
Norman



ALATL said:
I get an error when I try & pass the range object two variables. I have
tested this & it allows the use of one varaible. But I would like to use
two
variables to copy & paste cell A8:D8. Is there something wrong with my
syntax
or will I need to copy & paste one row at a time?


Dim UserName_Addr As String ' Where UserName_Addr = A8
Dim Resp_Addr As String ' Where Resp_Addr = D8

'Copy columns A,B,C, and D from Sheet 1 to Sheet 2
With Sheets("Sheet1")
.Range(.Range("UserName_Addr: Resp_Addr"),
.Range("A65536").End(xlUp)).Copy
End With
Sheets("Sheet2").[A65536].End(xlUp)(1).PasteSpecial Paste:=xlValues


Thx!
ALATL
 

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

Top