+ Reply to Thread
Results 1 to 5 of 5

Code won't work "as single"

Hybrid View

kevincoxshall Code won't work "as... 03-29-2014, 03:20 PM
mrice Re: Code won't work "as... 03-29-2014, 03:33 PM
mrice Re: Code won't work "as... 03-29-2014, 03:41 PM
Norie Re: Code won't work "as... 03-29-2014, 03:52 PM
kevincoxshall Re: Code won't work "as... 03-29-2014, 04:07 PM
  1. #1
    Registered User
    Join Date
    07-12-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2010
    Posts
    59

    Code won't work "as single"

    variable = ("=PEARSON(" & myfile1 & "!$F$1:$F$1000," & myfile2 & "!$F$1:$F$1000)")
    Dear all

    Above is a line of my code that calculates the "Pearson" function from 2 files.
    I'd like my variable to be defined "as single" but it causes an error unless I define "variable" as a string.

    Please help

    Kevin

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Code won't work "as single"

    If you are attempting to evaluate the function, you should try using

    Variable = WorksheetFunction.Pearson(Array1,Array2)

    You might need to use the INDIRECT function to define your arrays.

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Code won't work "as single"

    Sub Test()
    Dim Variable As Single
    Variable = WorksheetFunction.Pearson(Workbooks("Book2").Sheets(1).Range("A1:A16"), Workbooks("Book4").Sheets(1).Range("A1:A16"))
    End Sub
    Fuller example

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Code won't work "as single"

    Kevin

    Try this.

    variable = Evaluate("=PEARSON(" & myfile1 & "!$F$1:$F$1000," & myfile2 & "!$F$1:$F$1000)")
    PS You should probably declare variable as Variant in case of error.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    07-12-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Code won't work "as single"

    Thanks for all the replies.
    mrice ta for your code it works but the files need to be open to work it.
    Norie thanks I got your code to work perfect.
    I am very pleased
    thanks
    kevin

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 01-02-2014, 02:15 PM
  2. [SOLVED] Range("A1") = Sheets("Sheet2").CenterHeader.Text doesnt work.
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2013, 07:06 AM
  3. Replies: 1
    Last Post: 10-23-2013, 05:20 PM
  4. Open files from FTP server (works with "servername" but doesn't work with "ip address")
    By adammsu1983 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2012, 04:30 PM
  5. Replies: 4
    Last Post: 01-21-2008, 08:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1