#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Range error

Excel 2000

Can anybody help?

I get a " Method 'Range' of object '_Worksheet' failed " error message when
I run this code:

Private Sub Worksheet_selectionChange(ByVal Target As Range)

If ActiveCell = "Sun" Then

LUPVALUE = Range("f129")

result = Application.WorksheetFunction _
.VLookup(LUPVALUE, Range("testrange"), 2, False)

Application.StatusBar = "Total Orders = " & result
Else
Application.StatusBar = ""

End If
Application.Calculate
End Sub

Can you let me know how to fix this.

Regards

George


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Range error

It works okay if the valu looked up is found, so to cater for not finding,
try

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LUPVALUE, result

If ActiveCell = "Sun" Then

LUPVALUE = Range("f129")

result = Application.VLookup(LUPVALUE, Range("testrange"), 2, False)

If Not IsError(result) Then
Application.StatusBar = "Total Orders = " & result
Else
Application.StatusBar = ""
End If
Else
Application.StatusBar = ""

End If
Application.Calculate
End Sub

--
HTH

Bob Phillips

"George Andrews" wrote in message
...
Excel 2000

Can anybody help?

I get a " Method 'Range' of object '_Worksheet' failed " error message

when
I run this code:

Private Sub Worksheet_selectionChange(ByVal Target As Range)

If ActiveCell = "Sun" Then

LUPVALUE = Range("f129")

result = Application.WorksheetFunction _
.VLookup(LUPVALUE, Range("testrange"), 2, False)

Application.StatusBar = "Total Orders = " & result
Else
Application.StatusBar = ""

End If
Application.Calculate
End Sub

Can you let me know how to fix this.

Regards

George




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Range error

Bob

I am afraid this still does not work.

Nothing appears on the staus bar when I click on any cell that is not equal
to "Sun".

When I click on a cell with "sun" then I get the same error message as
before.

Any ideas?

Andrew


"Bob Phillips" wrote in message
...
It works okay if the valu looked up is found, so to cater for not finding,
try

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LUPVALUE, result

If ActiveCell = "Sun" Then

LUPVALUE = Range("f129")

result = Application.VLookup(LUPVALUE, Range("testrange"), 2,

False)

If Not IsError(result) Then
Application.StatusBar = "Total Orders = " & result
Else
Application.StatusBar = ""
End If
Else
Application.StatusBar = ""

End If
Application.Calculate
End Sub

--
HTH

Bob Phillips

"George Andrews" wrote in message
...
Excel 2000

Can anybody help?

I get a " Method 'Range' of object '_Worksheet' failed " error message

when
I run this code:

Private Sub Worksheet_selectionChange(ByVal Target As Range)

If ActiveCell = "Sun" Then

LUPVALUE = Range("f129")

result = Application.WorksheetFunction _
.VLookup(LUPVALUE, Range("testrange"), 2, False)

Application.StatusBar = "Total Orders = " & result
Else
Application.StatusBar = ""

End If
Application.Calculate
End Sub

Can you let me know how to fix this.

Regards

George






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Range error


"George Andrews" wrote in message
...
Bob

I am afraid this still does not work.

Nothing appears on the staus bar when I click on any cell that is not

equal
to "Sun".


That is b ecause your code clears the statusbar in this case.


When I click on a cell with "sun" then I get the same error message as
before.


If the looked up value is not found, I added code to clear the status bar
(as was your default). Is it found?


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
Range error Murray Excel Discussion (Misc queries) 1 August 20th 08 11:01 AM
out of range error Matilda New Users to Excel 9 September 18th 05 12:11 AM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Adding named range gives error "method range of object _Global failed " Gunnar Johansson Excel Programming 3 August 10th 04 01:54 PM


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