Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Converting col number to alpha letter to use in a range...

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Converting col number to alpha letter to use in a range...

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Converting col number to alpha letter to use in a range...

Worked like a charm Dave. Thanks much for the help!

CJM

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking up a value within a range of 3 letter or number codes... Jimmy Excel Worksheet Functions 6 June 4th 08 07:16 PM
formula converting number to column letter 26 KR Excel Worksheet Functions 5 March 2nd 06 04:29 PM
Converting a number to a letter in Excel Quinn Ramsey Excel Worksheet Functions 2 November 16th 05 11:29 PM
Converting a number to a letter in Excel Duke Carey Excel Worksheet Functions 0 November 16th 05 10:16 PM
How do I count the number of alpha occurences in a range? CRM Excel Worksheet Functions 2 May 30th 05 04:08 PM


All times are GMT +1. The time now is 10:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"