Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default column adjustments

I am writing the VBA code that is telling me what column a certain piece of
data is in...but instead of giving me the number of the column...is there
someway through VBA that it i can get the letter reference.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default column adjustments

The code you would use depends on what you are doing to locate the column.
For example, if you have the column number, you could do this...

ColNum = 4
ColLetter = Split(Columns(ColNum).Address(0,0),":")(0)

If you have a cell reference that is in that column, then you could do
this...

ColLetter = Split(CellReference.Address(1, 0), "$")(0)

There are lots of possibilities depending on what you are doing... can you
show us the code you have so we can give you a specific answer.

--
Rick (MVP - Excel)


"dstiefe" wrote in message
...
I am writing the VBA code that is telling me what column a certain piece of
data is in...but instead of giving me the number of the column...is there
someway through VBA that it i can get the letter reference.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default column adjustments

Here is a Function, courtesy Chip Pearson.

Function ColumnLetter(ColNumber) As String
ColumnLetter = Left(Cells(1, ColNumber).Address(True, False), _
1 - (ColNumber 26))
End Function


To use the function in code, assume you have set a column number to variable
myCol then:

myColLtr = ColumnLetter(myCol)

myColLtr will now equal an alpha column designation.

"dstiefe" wrote:

I am writing the VBA code that is telling me what column a certain piece of
data is in...but instead of giving me the number of the column...is there
someway through VBA that it i can get the letter reference.

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
Pivot adjustments walrus Excel Discussion (Misc queries) 1 January 18th 10 01:16 PM
Row Height Adjustments Janet Lyn[_2_] Excel Discussion (Misc queries) 3 March 25th 09 02:04 PM
Adjustments Andy New Users to Excel 4 January 21st 05 02:55 PM
Prevent Column adjustments? CLR Excel Programming 2 December 11th 04 03:05 PM
Help! need some adjustments! Simon Lloyd[_402_] Excel Programming 2 April 27th 04 10:03 PM


All times are GMT +1. The time now is 11:43 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"