![]() |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 05:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com