Referring to first cell in a range

F

FARAZ QURESHI

Hi Friends!

I am trying to write down my very first custom function code. The function
already requires the user to insert a range. Now, I also need to use the very
first cell of the range inserted so.

For example, the user inserts a range like:
A1:G1
or
A1:A6

I want to use the range as well as the very first cell, i.e. A1 in this
case. How can I refer to the very first one?

I have also tried the COLUMN(A1:G1) but its giving me an error in computation.

All help and expertise shall be highly obliged.

Best Regards,

FARAZ
 
E

excelent

Function Part(rng As Range, x)
Part = rng(x).Address
End Function

in ur sheet type :
=Part(A1:A4,1)
returns A1
=Part(A1:A4,2)
returns A2
=Part(A1:B4,1)
returns A1
=Part(A1:B4,2)
returns B1

and so on


"FARAZ QURESHI" skrev:
 
F

FARAZ QURESHI

Thanx brother,

But I want to generate Column(Part). I presume Part in this case is being
reflected as a String! How can I have the result of =Column(Part(A1:G1,1)) be
reflected as "1"?

Thanx again!
 
E

excelent

Returns as number:
=COLUMN(B1:G4)
Returns as text:
=TEXT(COLUMN(B1:G4),0)

if u mean vba function :
Function Part(rng As Range, x)
Part = rng(x).Column
End Function


"FARAZ QURESHI" skrev:
 
J

Jim May

Sub Tester()
Set MyRng = Range("A1:G1")
MsgBox "My first cell value is " & MyRng(1)
End Sub

HTH,
Jim
 
Top