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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This line of Code:

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

...comes up a couple of Columns short. The reason is obvious, the first of
the two missing Columns (T) is empty, but the one to the right of it (U)is
not. As I am selecting multiple Rows at the same time, and intend to run this
macro on a number of WS, each of which may or may not be populated in the
cells of those last two columns -- and may even find columns R and S empty
on some WS, but the number of Rows in each WS will vary, how do I tell the
Macro to Select the Columns I really want?
 
Without knowing "the columns you really want", perhaps:

Intersect(Selection.EntireRow, Range("C:U")).Select
 
Dave,

Range(Selection, Cells(Selection.Row, 256).End(xlToLeft)).Select

But, if there are additional columns that you don't want that are to the right of column U then use

Intersect(Selection.EntireRow, _
Range(Selection.EntireColumn, Range("U:U").EntireColumn)).Select

Though there isn't any need to Select the range....


HTH,
Bernie
MS Excel MVP
 

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