Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I get the column of a cell?
Range("B5").Select
? Left(ActiveCell.Columns.Address(, ColumnAbsolute:=False), 1) B Range("BB5").Select ? Left(ActiveCell.Columns.Address(, ColumnAbsolute:=False), 1) B -- Regards, Tom Ogilvy "debartsa" wrote in message ... Thanks Carim, I'll give it a try! "Carim" wrote in message oups.com... Hi Sam, Why don't you just add Left(x,1) Left(Target.Columns.Address(, ColumnAbsolute:=False), 1) HTH Cheers Carim |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I get the column of a cell?
Here's one possible solution using mod arithematic:
Sub GetSelectedColumn() Dim iCol As Integer Dim sCol As String iCol = ActiveCell.Column If iCol 26 Then sCol = Chr(Int(iCol / 26) + 64) & Chr((iCol Mod 26) + 64) Else sCol = Chr(iCol + 64) End If MsgBox sCol End Sub Notes: - Excel's columns go from A = 1 to IV = 256 - The Chr() function returns the character for a given ASCII value, where Chr(65) = 'A', Chr(66) = 'B', etc. - Int() truncates a division to the integer portion and Mod gives the remainder of the dision operation. These two values are then used to get the 1st and 2nd column identifiers. --Nick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Maddening Dilemma - Compare each cell within column a to each cell in column b and find unique matches | Excel Worksheet Functions | |||
Sum Cell Values of one column based on Another Cell Value in a different column | Excel Worksheet Functions | |||
compare cells in column to criteria, then average next column cell | Excel Worksheet Functions | |||
Need the formula or macro. If i enter today date in the cell (Row 1,Column 2) and on tab out, the column 1 cell should be filled with "corresponding Day" of the date | Excel Discussion (Misc queries) | |||
Format cell in column B based on value in the next cell (column c) | Excel Discussion (Misc queries) |