![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 11
|
Hi everyone,
I have written a funtion which has the following form: Function test(rng as Range) ... End Function and called it by test(A1:C10) My question is how do we know the column name in the function test? (i.e. how can we figure out the columns are A, B, and C. Thanks for any help |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Quote:
Function test(rng As Range) MsgBox rng.Address(False, False) MsgBox rng.Rows.Count MsgBox rng.Columns.Count MsgBox rng.Range("A1").Row End Function I don't know of any easy ways to get "A" for the first column, so it is probably best to get familiar with the R1C1 referencing method when using VBA. I never have it on the worksheet, but in VBA it is very useful. HTH, Jay |
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Hi megaxoom and Jay:
In the worksheet address function: =address(row_num,column_num,abs_num,a1,sheet_text) if Ihad row number 1, column number 1, abs_number =4, then =address(1,1,4,) will result in --> A1 I don't know if this is of any help, but I thought just in case ... Regards!
__________________
Regards! Yogi Anand, D.Eng, P.E. Energy Efficient Building Network LLC www.energyefficientbuild.com |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi megaxoom, and all,
How to figure out the column name using VBA is....
|
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Quote:
Please try these again.
|
|
|
|
|
|
|
#6 |
|
New Member
Join Date: May 2002
Posts: 11
|
You guys are great.
Thank you. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|