Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Referencing range name in calculation

I have the following three lines of code:

Dim a As Single
a = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, h).Value
a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), "OverheadLookup", 2)), 0)

I'm trying to perform a lookup using the range name "OverheadLookup" but I
get an error message when line 3 executes.

Any help would be greatly appreciated. Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Referencing range name in calculation

Hi Bob,

I think the problem is with closing brackets-
It should be like this

a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), "OverheadLookup", 2, 0)))

Hope this helps!!
--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"Bob" wrote:

I have the following three lines of code:

Dim a As Single
a = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, h).Value
a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), "OverheadLookup", 2)), 0)

I'm trying to perform a lookup using the range name "OverheadLookup" but I
get an error message when line 3 executes.

Any help would be greatly appreciated. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Referencing range name in calculation

Bob,

Try it like this:

a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), Range("OverheadLookup"), 2)), 0)


--
Hope that helps.

Vergel Adriano


"Bob" wrote:

I have the following three lines of code:

Dim a As Single
a = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, h).Value
a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), "OverheadLookup", 2)), 0)

I'm trying to perform a lookup using the range name "OverheadLookup" but I
get an error message when line 3 executes.

Any help would be greatly appreciated. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Referencing range name in calculation

Bob,

Try changing "OverheadLookup" for Range("OverheadLookup")

If the formula is correct, it should work.


"Bob" wrote:

I have the following three lines of code:

Dim a As Single
a = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, h).Value
a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), "OverheadLookup", 2)), 0)

I'm trying to perform a lookup using the range name "OverheadLookup" but I
get an error message when line 3 executes.

Any help would be greatly appreciated. Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Referencing range name in calculation

Hi Bob,
There are 2 problems one with the closing brackets and one with the 'cells'.
Your formula should be like this-

a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer).Value, "OverheadLookup", 2, 0)))

Hope this helps!!

--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"Bob" wrote:

I have the following three lines of code:

Dim a As Single
a = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, h).Value
a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), "OverheadLookup", 2)), 0)

I'm trying to perform a lookup using the range name "OverheadLookup" but I
get an error message when line 3 executes.

Any help would be greatly appreciated. Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Referencing range name in calculation

Thanks to everyone for your helpful suggestions. In addition to omitting
"Range", I realized that "Cells(Sheet1RowPointer, Sheet1RespCodeColPointer)"
references a string (rather than a value). So the solution is as follows:

Dim RespCode As String
Dim a As Single

RespCode = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer)

a = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, h).Value

a = Round(a * (1 + WorksheetFunction.VLookup(RespCode, _
Range("OverheadLookup"), 2)), 0)

Thanks again,
Bob


"Bob" wrote:

I have the following three lines of code:

Dim a As Single
a = Worksheets(Sheet1Name).Cells(Sheet1RowPointer, h).Value
a = Round(a * (1 + WorksheetFunction.VLookup(Cells(Sheet1RowPointer, _
Sheet1RespCodeColPointer), "OverheadLookup", 2)), 0)

I'm trying to perform a lookup using the range name "OverheadLookup" but I
get an error message when line 3 executes.

Any help would be greatly appreciated. Thanks.

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
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
Referencing a Range Sanj Excel Programming 2 June 17th 05 12:45 AM
Referencing same cell in calculation Tugger Excel Programming 4 February 12th 05 04:23 PM
range referencing lakey13[_4_] Excel Programming 0 November 9th 04 03:38 PM
range.calculation with UDF not working when calculation is set to automatic Brian Murphy Excel Programming 5 October 14th 03 07:02 PM


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