#1   Report Post  
Mark1
 
Posts: n/a
Default VBA .Find question

Can anybody tell me why I get the error "Unable to get the Find property of
the Range Class" here? I passed the variable a to MyTest5(b). I assumed
that MyTest5 would Find a in the range "Name". Help is appreciated!

Sub MyTest()

Dim a As String
Dim c

a = Worksheets("Input Sheet").Range("C3").Value
c = Application.Match(a, Worksheets("Sheet2").Range("Name"), 0)

If Not IsError(c) Then
Dim mymessage As String

mymessage = "This name has already been entered." & Chr(13) _
& "Would you like to retrieve that listing?"
Style = vbYesNo
Response = MsgBox(mymessage, Style)

If Response = vbYes Then
Call MyTest5(a)
Else: GoTo Option3
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

Sub MyTest5(b As String)

With Worksheets(2).Range("Name")
Set d = .Find(b, , xlValues, xlWhole)
If Not d Is Nothing Then
  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

VBA is not finding a range named "Name" in Worksheets(2).

Note that Worksheets(2) will be different than Sheets("Sheet2") if the
sheet named "Sheet2" is not the second sheet from left to right in the
worksheet tabs.


In article ,
"Mark1" wrote:

Can anybody tell me why I get the error "Unable to get the Find property of
the Range Class" here? I passed the variable a to MyTest5(b). I assumed
that MyTest5 would Find a in the range "Name". Help is appreciated!

Sub MyTest()

Dim a As String
Dim c

a = Worksheets("Input Sheet").Range("C3").Value
c = Application.Match(a, Worksheets("Sheet2").Range("Name"), 0)

If Not IsError(c) Then
Dim mymessage As String

mymessage = "This name has already been entered." & Chr(13) _
& "Would you like to retrieve that listing?"
Style = vbYesNo
Response = MsgBox(mymessage, Style)

If Response = vbYes Then
Call MyTest5(a)
Else: GoTo Option3
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

Sub MyTest5(b As String)

With Worksheets(2).Range("Name")
Set d = .Find(b, , xlValues, xlWhole)
If Not d Is Nothing Then

  #3   Report Post  
Mark1
 
Posts: n/a
Default

"Sheet2" and Sheet(2) are the same thing. There's only two sheets in the
workbook. And Column A is named "Name"

"JE McGimpsey" wrote:

VBA is not finding a range named "Name" in Worksheets(2).

Note that Worksheets(2) will be different than Sheets("Sheet2") if the
sheet named "Sheet2" is not the second sheet from left to right in the
worksheet tabs.


In article ,
"Mark1" wrote:

Can anybody tell me why I get the error "Unable to get the Find property of
the Range Class" here? I passed the variable a to MyTest5(b). I assumed
that MyTest5 would Find a in the range "Name". Help is appreciated!

Sub MyTest()

Dim a As String
Dim c

a = Worksheets("Input Sheet").Range("C3").Value
c = Application.Match(a, Worksheets("Sheet2").Range("Name"), 0)

If Not IsError(c) Then
Dim mymessage As String

mymessage = "This name has already been entered." & Chr(13) _
& "Would you like to retrieve that listing?"
Style = vbYesNo
Response = MsgBox(mymessage, Style)

If Response = vbYes Then
Call MyTest5(a)
Else: GoTo Option3
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

Sub MyTest5(b As String)

With Worksheets(2).Range("Name")
Set d = .Find(b, , xlValues, xlWhole)
If Not d Is Nothing Then


  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

In that case, it works for me. Here's my test workbook:

ftp://ftp.mcgimpsey.com/excel/mark1_demo.xls


In article ,
"Mark1" wrote:

Can anybody tell me why I get the error "Unable to get the Find property of
the Range Class" here? I passed the variable a to MyTest5(b). I assumed
that MyTest5 would Find a in the range "Name". Help is appreciated!

Sub MyTest()

Dim a As String
Dim c

a = Worksheets("Input Sheet").Range("C3").Value
c = Application.Match(a, Worksheets("Sheet2").Range("Name"), 0)

If Not IsError(c) Then
Dim mymessage As String

mymessage = "This name has already been entered." & Chr(13) _
& "Would you like to retrieve that listing?"
Style = vbYesNo
Response = MsgBox(mymessage, Style)

If Response = vbYes Then
Call MyTest5(a)
Else: GoTo Option3
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

Sub MyTest5(b As String)

With Worksheets(2).Range("Name")
Set d = .Find(b, , xlValues, xlWhole)
If Not d Is Nothing Then

  #5   Report Post  
Mark1
 
Posts: n/a
Default

OK,
Here's something I discovered. When I run the macro from inside the VBE
using the F8 key, it works. However, when I run it using the command button
on my spreadsheet, it doesn't work. Any ideas?

"JE McGimpsey" wrote:

In that case, it works for me. Here's my test workbook:

ftp://ftp.mcgimpsey.com/excel/mark1_demo.xls


In article ,
"Mark1" wrote:

Can anybody tell me why I get the error "Unable to get the Find property of
the Range Class" here? I passed the variable a to MyTest5(b). I assumed
that MyTest5 would Find a in the range "Name". Help is appreciated!

Sub MyTest()

Dim a As String
Dim c

a = Worksheets("Input Sheet").Range("C3").Value
c = Application.Match(a, Worksheets("Sheet2").Range("Name"), 0)

If Not IsError(c) Then
Dim mymessage As String

mymessage = "This name has already been entered." & Chr(13) _
& "Would you like to retrieve that listing?"
Style = vbYesNo
Response = MsgBox(mymessage, Style)

If Response = vbYes Then
Call MyTest5(a)
Else: GoTo Option3
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

Sub MyTest5(b As String)

With Worksheets(2).Range("Name")
Set d = .Find(b, , xlValues, xlWhole)
If Not d Is Nothing Then




  #6   Report Post  
JE McGimpsey
 
Posts: n/a
Default

Set the Button's TakeFocusOnClick property to False.

In article ,
"Mark1" wrote:

Here's something I discovered. When I run the macro from inside the VBE
using the F8 key, it works. However, when I run it using the command button
on my spreadsheet, it doesn't work. Any ideas?

  #7   Report Post  
Mark1
 
Posts: n/a
Default

Sweet mercy, it worked!!!!!!
Thanks a million!

"JE McGimpsey" wrote:

Set the Button's TakeFocusOnClick property to False.

In article ,
"Mark1" wrote:

Here's something I discovered. When I run the macro from inside the VBE
using the F8 key, it works. However, when I run it using the command button
on my spreadsheet, it doesn't work. Any ideas?


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
basic pie chart question KayR Charts and Charting in Excel 4 January 23rd 05 08:16 PM
Jon Peltier - Pivot Table Result for yesterday's "Complex Chart" Question Barb Reinhardt Charts and Charting in Excel 3 December 8th 04 01:48 AM
Well that's strange... TAB question CrankyLemming Excel Discussion (Misc queries) 3 December 1st 04 07:52 AM
Paste Special Question Kevin Excel Discussion (Misc queries) 3 November 30th 04 11:34 PM
Question Startup Switches greg Excel Discussion (Misc queries) 2 November 29th 04 11:07 PM


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

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

About Us

"It's about Microsoft Excel"