Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default excel function help

I have two ranges named PReq and QOutput.

I have this procedu

Sub test_dependency()
Call dependency(Worksheets("PP"), [PReq], [QOutput], "testtitle")
End Sub

And I have:

Sub dependency(Result As Worksheet, Ratiorange As Range, Qrange As
Range, Title As String)
row_id = some array which results in a value
[Yearstart].value = 5
rowitem = 5
colitem = 5
z=10
Result.Cells(rowwriter, z).formula = "=vlookup(" & row_id(rowitem, 1)
& "," & Qrange.name & "," & z - [Yearstart].Value + 1 & ",false) *
index(" & Ratiorange.name & "," & rowitem & "," & colitem & ")"


I desperately want the formula to look like:

=vlookup(4,PReq,6,false)*index(QOutput,5,5)

I'll take

=vlookup(4,PReq!$b$5:$h$100,6,false)*index(QOutput !$b$5:$g$10,5,5)

but I get

=vlookup(4,=PReq!$b$5:$h$100,6,false)*index(=QOutp ut!$b$5:$g$10,5,5)

I've tried Qrange.name, .address, .value, .text anything. they all
dont' work. Then I tried to go through the Locals window and when I
clicked onto Qrange - Cells - Name, lo and behold, it was "QOutput".
So then I tried

?Qrange.cells.name in the immediate window and got a syntax error

same with:

?[Qrange].cells.name and ?Range("QRange").cells.name

Tell me your learning curve is as steep as mine because this should be
very obvious
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 248
Default excel function help

If you just want to build a formula then simply pass PReq and Qouput as
strings... why use them as Range in the function call?

Also to get the address of the defined names use
PReq.RefersToRange.Address
instead of
PReq.Name

Try (after verifying the quotes placement...

Sub test_dependency()
Call dependency(Worksheets("Sheet1"), "PReq", "QOutput", "testtitle")
End Sub

Sub dependency(Result As Worksheet, Ratiorange As String, Qrange As String,
Title As String)
'row_id = some array which results in a value
[Yearstart].Value = 5
rowitem = 5
colitem = 5
z = 10
Result.Cells(rowwriter, z).Formula = "=vlookup(" & row_id(rowitem, 1) _
& ", Qrange," & z - [Yearstart].Value + 1 & _
",false) * index(Ratiorange," & rowitem & "," & colitem & ")"
End Sub
--
Pl click the YES button
(if you see it - don''''''''t worry if you don''t),
if this answer was helpful.



" wrote:

I have two ranges named PReq and QOutput.

I have this procedu

Sub test_dependency()
Call dependency(Worksheets("PP"), [PReq], [QOutput], "testtitle")
End Sub

And I have:

Sub dependency(Result As Worksheet, Ratiorange As Range, Qrange As
Range, Title As String)
row_id = some array which results in a value
[Yearstart].value = 5
rowitem = 5
colitem = 5
z=10
Result.Cells(rowwriter, z).formula = "=vlookup(" & row_id(rowitem, 1)
& "," & Qrange.name & "," & z - [Yearstart].Value + 1 & ",false) *
index(" & Ratiorange.name & "," & rowitem & "," & colitem & ")"


I desperately want the formula to look like:

=vlookup(4,PReq,6,false)*index(QOutput,5,5)

I'll take

=vlookup(4,PReq!$b$5:$h$100,6,false)*index(QOutput !$b$5:$g$10,5,5)

but I get

=vlookup(4,=PReq!$b$5:$h$100,6,false)*index(=QOutp ut!$b$5:$g$10,5,5)

I've tried Qrange.name, .address, .value, .text anything. they all
dont' work. Then I tried to go through the Locals window and when I
clicked onto Qrange - Cells - Name, lo and behold, it was "QOutput".
So then I tried

?Qrange.cells.name in the immediate window and got a syntax error

same with:

?[Qrange].cells.name and ?Range("QRange").cells.name

Tell me your learning curve is as steep as mine because this should be
very obvious

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default excel function help

On Apr 14, 3:21*pm, Sheeloo just
remove all As... wrote:
If you just want to build a formula then simply pass PReq and Qouput as
strings... why use them as Range in the function call?

Also to get the address of the defined names use
PReq.RefersToRange.Address
instead of
PReq.Name

Try (after verifying the quotes placement...

Sub test_dependency()
Call dependency(Worksheets("Sheet1"), "PReq", "QOutput", "testtitle")
End Sub

Sub dependency(Result As Worksheet, Ratiorange As String, Qrange As String,
Title As String)
'row_id = some array which results in a value
[Yearstart].Value = 5
rowitem = 5
colitem = 5
z = 10
Result.Cells(rowwriter, z).Formula = "=vlookup(" & row_id(rowitem, 1) _
& ", Qrange," & z - [Yearstart].Value + 1 & _
",false) * index(Ratiorange," & rowitem & "," & colitem & ")"
End Sub
--
Pl click the YES button
(if you see it - don''''''''t worry if you don''t),
if this answer was helpful.



" wrote:
I have two ranges named PReq and QOutput.


I have this procedu


Sub test_dependency()
Call dependency(Worksheets("PP"), [PReq], [QOutput], "testtitle")
End Sub


And I have:


Sub dependency(Result As Worksheet, Ratiorange As Range, Qrange As
Range, Title As String)
row_id = some array which results in a value
[Yearstart].value = 5
rowitem = 5
colitem = 5
z=10
Result.Cells(rowwriter, z).formula = "=vlookup(" & row_id(rowitem, 1)
& "," & Qrange.name & "," & z - [Yearstart].Value + 1 & ",false) *
index(" & Ratiorange.name & "," & rowitem & "," & colitem & ")"


I desperately want the formula to look like:


=vlookup(4,PReq,6,false)*index(QOutput,5,5)


I'll take


=vlookup(4,PReq!$b$5:$h$100,6,false)*index(QOutput !$b$5:$g$10,5,5)


but I get


=vlookup(4,=PReq!$b$5:$h$100,6,false)*index(=QOutp ut!$b$5:$g$10,5,5)


I've tried Qrange.name, .address, .value, .text anything. they all
dont' work. Then I tried to go through the Locals window and when I
clicked onto Qrange - Cells - Name, lo and behold, it was "QOutput".
So then I tried


?Qrange.cells.name in the immediate window and got a syntax error


same with:


?[Qrange].cells.name and ?Range("QRange").cells.name


Tell me your learning curve is as steep as mine because this should be
very obvious- Hide quoted text -


- Show quoted text -


Really? Is that the best that Microsoft can do? I was going to use
the ranges as both a range and a function. There's no property to
putt the name of the range? That's too bad. Thanks for your help. I
must be doing something uncommon if I want ot use a range in a
procedure to refer to cell values and I want to use it to build up a
formula both in the same procedure
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 248
Default excel function help

Try
Sub listNames()
Set nms = ActiveWorkbook.Names
Set wks = Worksheets(1)
For r = 1 To nms.Count
wks.Cells(r, 2).Value = nms(r).Name
wks.Cells(r, 3).Value = nms(r).RefersToRange.Address
Next
End Sub

Just noticed that you are passing PReq as range and not as Name
Range does not have a name property... as it has no name

--
Pl click the YES button
(if you see it - don''''''''t worry if you don''t),
if this answer was helpful.



" wrote:



Really? Is that the best that Microsoft can do? I was going to use
the ranges as both a range and a function. There's no property to
putt the name of the range? That's too bad. Thanks for your help. I
must be doing something uncommon if I want ot use a range in a
procedure to refer to cell values and I want to use it to build up a
formula both in the same procedure

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 968
Default excel function help

see response in Programming

Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

wrote in message
...
On Apr 14, 3:21 pm, Sheeloo just
remove all As... wrote:
If you just want to build a formula then simply pass PReq and Qouput as
strings... why use them as Range in the function call?

Also to get the address of the defined names use
PReq.RefersToRange.Address
instead of
PReq.Name

Try (after verifying the quotes placement...

Sub test_dependency()
Call dependency(Worksheets("Sheet1"), "PReq", "QOutput", "testtitle")
End Sub

Sub dependency(Result As Worksheet, Ratiorange As String, Qrange As
String,
Title As String)
'row_id = some array which results in a value
[Yearstart].Value = 5
rowitem = 5
colitem = 5
z = 10
Result.Cells(rowwriter, z).Formula = "=vlookup(" & row_id(rowitem, 1) _
& ", Qrange," & z - [Yearstart].Value + 1 & _
",false) * index(Ratiorange," & rowitem & "," & colitem & ")"
End Sub
--
Pl click the YES button
(if you see it - don''''''''t worry if you don''t),
if this answer was helpful.



" wrote:
I have two ranges named PReq and QOutput.


I have this procedu


Sub test_dependency()
Call dependency(Worksheets("PP"), [PReq], [QOutput], "testtitle")
End Sub


And I have:


Sub dependency(Result As Worksheet, Ratiorange As Range, Qrange As
Range, Title As String)
row_id = some array which results in a value
[Yearstart].value = 5
rowitem = 5
colitem = 5
z=10
Result.Cells(rowwriter, z).formula = "=vlookup(" & row_id(rowitem, 1)
& "," & Qrange.name & "," & z - [Yearstart].Value + 1 & ",false) *
index(" & Ratiorange.name & "," & rowitem & "," & colitem & ")"


I desperately want the formula to look like:


=vlookup(4,PReq,6,false)*index(QOutput,5,5)


I'll take


=vlookup(4,PReq!$b$5:$h$100,6,false)*index(QOutput !$b$5:$g$10,5,5)


but I get


=vlookup(4,=PReq!$b$5:$h$100,6,false)*index(=QOutp ut!$b$5:$g$10,5,5)


I've tried Qrange.name, .address, .value, .text anything. they all
dont' work. Then I tried to go through the Locals window and when I
clicked onto Qrange - Cells - Name, lo and behold, it was "QOutput".
So then I tried


?Qrange.cells.name in the immediate window and got a syntax error


same with:


?[Qrange].cells.name and ?Range("QRange").cells.name


Tell me your learning curve is as steep as mine because this should be
very obvious- Hide quoted text -


- Show quoted text -


Really? Is that the best that Microsoft can do? I was going to use
the ranges as both a range and a function. There's no property to
putt the name of the range? That's too bad. Thanks for your help. I
must be doing something uncommon if I want ot use a range in a
procedure to refer to cell values and I want to use it to build up a
formula both in the same procedure


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
Help to build a Look Up Function or What Ever Function Excel 2002 Carlo Excel Worksheet Functions 6 April 3rd 08 07:39 PM
copy of excel file not showing formulal/function in the function b oaallam Excel Discussion (Misc queries) 4 September 6th 07 01:20 PM
challenge! javascript function into excel function Kamila Excel Worksheet Functions 2 February 19th 07 06:35 AM
Excel Workday Function with another function Monique Excel Discussion (Misc queries) 2 April 27th 06 01:11 PM
Can you nest a MID function within a IF function in Excel Dawn-Anne Excel Worksheet Functions 2 March 4th 05 01:37 PM


All times are GMT +1. The time now is 11:36 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"