#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default RT- error 1004

In cell A1 I have:
A,B,C,D,E
In Cell I have:
=LEN(A1)-(LEN(SUBSTITUTE(A1,",",""))-1)

which produces 5 << as I expect

I'm wanting to enter this formula via VBA (a button) as follows:

Sub FindUnique()
ActiveSheet.Range("C3").Formula =
"=LEN($A$1)-(LEN(SUBSTITUTE($A$1),"","",""""))-1)"
End Sub

but it doesn't work. What am I doing wrong here...???

TIA,





  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default RT- error 1004

Try this

Sub FindUnique()
ActiveSheet.Range("C3").Formula = _
"=LEN(SUBSTITUTE(A1,"","",""""))"
End Sub

Mike

"JMay" wrote:

In cell A1 I have:
A,B,C,D,E
In Cell I have:
=LEN(A1)-(LEN(SUBSTITUTE(A1,",",""))-1)

which produces 5 << as I expect

I'm wanting to enter this formula via VBA (a button) as follows:

Sub FindUnique()
ActiveSheet.Range("C3").Formula =
"=LEN($A$1)-(LEN(SUBSTITUTE($A$1),"","",""""))-1)"
End Sub

but it doesn't work. What am I doing wrong here...???

TIA,





  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default RT- error 1004

You had an extra closing parenthsis in the VBA code. I often assign a
formula to a string variable to help diagnosis problems. when yuo have
parenthesis inside a formula these are sometimes problems. I can use debug
techniques to look at FORM below to help find the problems.


Sub FindUnique()
form = "=LEN($A$1)-(LEN(SUBSTITUTE($A$1,"","",""""))-1)"
Range("C3").Formula = form

End Sub

"JMay" wrote:

In cell A1 I have:
A,B,C,D,E
In Cell I have:
=LEN(A1)-(LEN(SUBSTITUTE(A1,",",""))-1)

which produces 5 << as I expect

I'm wanting to enter this formula via VBA (a button) as follows:

Sub FindUnique()
ActiveSheet.Range("C3").Formula =
"=LEN($A$1)-(LEN(SUBSTITUTE($A$1),"","",""""))-1)"
End Sub

but it doesn't work. What am I doing wrong here...???

TIA,





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default RT- error 1004

Thanks guys... (not sure how this extra ")" got in there. Thanks Joel for
the suggestion regarding the variable assignment. I need to remember that
going forward.

Jim

"Joel" wrote:

You had an extra closing parenthsis in the VBA code. I often assign a
formula to a string variable to help diagnosis problems. when yuo have
parenthesis inside a formula these are sometimes problems. I can use debug
techniques to look at FORM below to help find the problems.


Sub FindUnique()
form = "=LEN($A$1)-(LEN(SUBSTITUTE($A$1,"","",""""))-1)"
Range("C3").Formula = form

End Sub

"JMay" wrote:

In cell A1 I have:
A,B,C,D,E
In Cell I have:
=LEN(A1)-(LEN(SUBSTITUTE(A1,",",""))-1)

which produces 5 << as I expect

I'm wanting to enter this formula via VBA (a button) as follows:

Sub FindUnique()
ActiveSheet.Range("C3").Formula =
"=LEN($A$1)-(LEN(SUBSTITUTE($A$1),"","",""""))-1)"
End Sub

but it doesn't work. What am I doing wrong here...???

TIA,





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
why am i getting an error 1004?? please help SAM SEBAIHI Excel Discussion (Misc queries) 2 February 16th 07 02:21 AM
error 1004 (VBA) vsiat Excel Discussion (Misc queries) 1 May 15th 06 07:17 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM


All times are GMT +1. The time now is 07:14 AM.

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"