Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 477
Default Incorrect usage of VBA WSfunction


..... Omission of lines
str1 = Right(Target.Formula, Len(Target.Formula) - 1)
If WorksheetFunction.Find("!", str1) = Err Then Exit Sub << Not Right !!

line 2 above tests for - If the formula str1 DOES NOT refer to another Sheet
(with !)
then exit Sub

But what is (Right)?

TIA,

Jim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Incorrect usage of VBA WSfunction

Look at InStr in VBA's help.



Jim May wrote:

.... Omission of lines
str1 = Right(Target.Formula, Len(Target.Formula) - 1)
If WorksheetFunction.Find("!", str1) = Err Then Exit Sub << Not Right !!

line 2 above tests for - If the formula str1 DOES NOT refer to another Sheet
(with !)
then exit Sub

But what is (Right)?

TIA,

Jim


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Incorrect usage of VBA WSfunction

Since you are running in VBA, use the INSTR function to search for "!"

i.e.
If Target.Formula < "" Then
str1 = Right(Target.Formula, Len(Target.Formula) - 1)
If InStr(str1, "!") = 0 Then Exit Sub
End If

Please not that "!" does not ensure the formula refers to a separate
worksheet, it could very well refer to the active worksheet.

--
Les Torchia-Wells


"Jim May" wrote:


.... Omission of lines
str1 = Right(Target.Formula, Len(Target.Formula) - 1)
If WorksheetFunction.Find("!", str1) = Err Then Exit Sub << Not Right !!

line 2 above tests for - If the formula str1 DOES NOT refer to another Sheet
(with !)
then exit Sub

But what is (Right)?

TIA,

Jim


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Incorrect usage of VBA WSfunction

iserror test for an error, but use the vba Instr for this

If Instr(1,str1,"!",vbTextcompare) = 0 Then Exit Sub

--
Regards,
Tom Ogilvy


"Jim May" wrote:


.... Omission of lines
str1 = Right(Target.Formula, Len(Target.Formula) - 1)
If WorksheetFunction.Find("!", str1) = Err Then Exit Sub << Not Right !!

line 2 above tests for - If the formula str1 DOES NOT refer to another Sheet
(with !)
then exit Sub

But what is (Right)?

TIA,

Jim


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 477
Default Incorrect usage of VBA WSfunction

Got it !!
Tks,
Jim

"Tom Ogilvy" wrote:

iserror test for an error, but use the vba Instr for this

If Instr(1,str1,"!",vbTextcompare) = 0 Then Exit Sub

--
Regards,
Tom Ogilvy


"Jim May" wrote:


.... Omission of lines
str1 = Right(Target.Formula, Len(Target.Formula) - 1)
If WorksheetFunction.Find("!", str1) = Err Then Exit Sub << Not Right !!

line 2 above tests for - If the formula str1 DOES NOT refer to another Sheet
(with !)
then exit Sub

But what is (Right)?

TIA,

Jim




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
Sumproduct() usage Jim May Excel Discussion (Misc queries) 2 January 11th 08 09:55 PM
limited usage jinvictor Excel Discussion (Misc queries) 1 June 14th 06 04:28 PM
100% cpu usage bill Excel Discussion (Misc queries) 1 March 2nd 06 10:27 AM
SQL - TOP 1 Usage ell[_2_] Excel Programming 6 August 26th 04 12:08 AM
CopyFile usage Garry[_5_] Excel Programming 1 January 19th 04 08:56 PM


All times are GMT +1. The time now is 10:15 AM.

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"