selecting data in a row

  • Thread starter Thread starter darkblue
  • Start date Start date
D

darkblue

Dim rng As Range
With Worksheets("Data")
Set rng = .Range("a2", .Range("a" & Rows.count).End(xlUp))
End With
rng.Select
--------------------

With above code I select all data in column A.
How can I select all data in row 1.
I mean what is the equal code for selecting columns in a row ?
Thank you.
 
HI

Look at this:

Dim Rng2 As Range
With Worksheets("Data")
Set rng = .Range("a2", .Range("a" & Columns.Count).End(xlToLeft))
End With

Regards,
Per
 
HI

Look at this:

Dim Rng2 As Range
With Worksheets("Data")
       Set rng = .Range("a2", .Range("a" & Columns.Count).End(xlToLeft))
End With

Regards,
Per

"darkblue" <[email protected]> skrev i meddelelsen




- Show quoted text -


Thank you so much Per.
 
Hi,

One way with the usual caveat that it is very unlikely you need to select
the range to do what you want.

Dim rng As Range
With Worksheets("Sheet1")
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
Set rng = .Range(Cells(1, 1), Cells(1, LastCol))
End With
rng.Select

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Hi,

One way with the usual caveat that it is very unlikely you need to select
the range to do what you want.

Dim rng As Range
With Worksheets("Sheet1")
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
Set rng = .Range(Cells(1, 1), Cells(1, LastCol))
End With
rng.Select

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.







- Show quoted text -

Thank you very much Mike.
 
Back
Top