PC Review


Reply
Thread Tools Rate Thread

Converting col number to alpha letter to use in a range...

 
 
Lakehills
Guest
Posts: n/a
 
      4th Jan 2007
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

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      4th Jan 2007
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
 
Reply With Quote
 
Lakehills
Guest
Posts: n/a
 
      4th Jan 2007
Worked like a charm Dave. Thanks much for the help!

CJM

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting a number to a letter in Excel =?Utf-8?B?UXVpbm4gUmFtc2V5?= Microsoft Excel Worksheet Functions 2 16th Nov 2005 11:29 PM
RE: Converting a number to a letter in Excel =?Utf-8?B?RHVrZSBDYXJleQ==?= Microsoft Excel Worksheet Functions 0 16th Nov 2005 10:16 PM
How do I count the number of alpha occurences in a range? =?Utf-8?B?Q1JN?= Microsoft Excel Worksheet Functions 2 30th May 2005 04:08 PM
Converting Col Number to Col Letter SidBord Microsoft Excel Misc 1 23rd May 2004 11:05 PM
Converting a letter (text) to a number =?Utf-8?B?Tkw=?= Microsoft Access Queries 1 23rd Jan 2004 04:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 AM.