selecting data in a row

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.
 
P

Per Jessen

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
 
D

darkblue

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.
 
M

Mike H

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.
 
D

darkblue

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.
 

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