Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default Referring to first cell in a range

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Referring to first cell in a range

Cells(1,1)

"FARAZ QURESHI" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 695
Default Referring to first cell in a range

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:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default Referring to first cell in a range

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!

"excelent" wrote:

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:

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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 695
Default Referring to first cell in a range

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:

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!

"excelent" wrote:

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:

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



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 477
Default Referring to first cell in a range

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

HTH,
Jim

"FARAZ QURESHI" wrote:

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

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
Formula referring to a dynamic range in a different workbook mr tom Excel Worksheet Functions 6 March 29th 07 08:56 AM
Sum values referring to a cell with same value ghnogueira Excel Discussion (Misc queries) 3 March 23rd 07 09:11 PM
Sumif referring to range names formulas not updating Excel_Still_Stumps_ME Excel Worksheet Functions 1 September 19th 06 08:14 PM
How do I use indirect when referring to a named range in a closed Ed Green Excel Worksheet Functions 3 May 22nd 06 08:01 PM
How to return a value Referring to the other cell. ramana Excel Worksheet Functions 6 November 7th 05 09:11 AM


All times are GMT +1. The time now is 06:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"