Selection problem with recorder

B

Brian

My data distribution looks like this:

Col1 Col2 Col3 -------- Col20 Col21 Col22 Col23
data1 data3 -------- data20
data23

Using the Macro recorder , I selected data1 to data23, by pressing
Ctrl-Shift and the right pointing arrow (=>) three times. The relevent codes
generated are as follows:

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

However, when I executed them, Excel carried out the first line correctly
but stepped over the last two lines without carrying them out. What's wrong?
There will always be 3 blank columns, but more columns will be added after
Col20 to accept more data. Hence, Range("A1:W1").Select can't be used. Any
suggestion is much appreciated.

Brian
 
B

Brian

Tom Ogilvy said:
Range(Cells(1,1),Cells(1,"IV").End(xltoLeft)).Select

This is ok if data1 is in Row 1. Sorry for not being more specific.
My data1 can be in any random row location, resulting from a sort.
Therefore, I need to select from the position of the active cell across
to the right.

Thanx
Brian
 

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