Range("a1",cells(1,lastcol)).select
is one way.
range("a1:a" & lastcol).select
is another
Lakehills wrote:
>
> Hello all,
>
> This is probably a stupid question, but here goes...
>
> My task is to select all the cells in row one (the header row) that
> have data in them so I can apply formatting to them.
>
> With the code below, I determine the last used colum, but "LastColumn"
> is an integer. Assuming the first column is "A" and the row is always
> 1, how can I format the range statement? (or is there another way to
> do this?)
>
> ' Determine last used column...
>
> If WorksheetFunction.CountA(Cells) > 0 Then
> 'Search for any entry, by searching backwards by Columns.
> LastColumn = Cells.Find(What:="*", After:=[A1], _
> SearchOrder:=xlByColumns, _
> SearchDirection:=xlPrevious).Column
> MsgBox LastColumn
> End If
>
> ' Select range ...
> Range("A1:?1").Select
>
> Can someone point me in the right direction?
>
> Thanks,
> CJM
--
Dave Peterson
|