Select Range Using R1C1

Dathan Camacho

New Member
Joined
Mar 30, 2010
Messages
37
Hi, I need some help with syntax.

Assume I have 3 variables successfully defined and working:

LastRow1 (original last row before new data pasted)
LastRow2 (new last row after new data pasted)
LastColumn

I'm trying to select the range of cells starting with column 13 and letting the other part of the range be defined by these variables. I.e. I want to select:

.Cells(LastRow+1,13) to .cells(LastRow2,LastColumn)

Can someone help me with the syntax?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try:

Range(.Cells(LastRow+1,13),.cells(LastRow2,LastColumn).Select

Noting that you rarely need to select.

HTH,
 
Upvote 0
I'm using this code to copy a dynamic range of cells. I'm getting an error.

Code:
.Range(.Cells(ReceiptsLastRow + 1, 13), .Cells(ReceiptsLastRow2, LastColumnD)).Select

The error is "select method of Range class failed". Can someone advise? Thanks!
 
Upvote 0
Can you show where you're setting your variables?

Because this works just fine:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> ws <SPAN style="color:#00007F">As</SPAN> Worksheet<br>    <SPAN style="color:#00007F">Dim</SPAN> ReceiptsLastRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, ReceiptsLastRow2 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, LastColumnD <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>        <br>        <SPAN style="color:#00007F">Set</SPAN> ws = Sheets("Sheet1")<br>        <br>        ReceiptsLastRow = 10<br>        ReceiptsLastRow2 = 10<br>        LastColumnD = 10<br>    <br>        <SPAN style="color:#00007F">With</SPAN> ws<br>            .Range(.Cells(ReceiptsLastRow + 1, 13), .Cells(ReceiptsLastRow2, LastColumnD)).Select<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,004
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top