Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Trouble with passing a range into worksheet function in VBA

------ Hi i am having a lot of trouble with the following piece of
code.

ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[50]C,sheet1!R[51]C:R[100]C,2,2)"

--- This code looks for the p value within the two groups of a single
column. There are 200 columns, and all the columns are arranged so that
the first 50 value belongs to one group and the second fifty values
belongs to the other. I am trying to write a macro to automate the
results of 200 individual ttest for 200 columns from sheet 1 and write
them to sheet 2. While this piece of code works most of the time, its
not dynamic enough to take into account the situation where the ratio
changes for every new 200 ttest it has to perform. For example, the
first workbook will have columns with the first 50 that is one group
and the second 50 in another, and the second work book will have
columns with the first 40 cells that is group one and the next 60 cells
in group two. I've tried

ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[K]C,sheet1!R[K+1]C:R[100]C,2,2)"


by inserting a variable into the column argument and changing k for
each new workbook, however, that does not work. Can someone please
suggest something?


cheers, and thanks ahead of time.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Trouble with passing a range into worksheet function in VBA

ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[" & K & "]C,sheet1!R[" & K &
"+1]C:R[100]C,2,2)"


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


wrote in message
ups.com...
------ Hi i am having a lot of trouble with the following piece of
code.

ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[50]C,sheet1!R[51]C:R[100]C,2,2)"

--- This code looks for the p value within the two groups of a single
column. There are 200 columns, and all the columns are arranged so that
the first 50 value belongs to one group and the second fifty values
belongs to the other. I am trying to write a macro to automate the
results of 200 individual ttest for 200 columns from sheet 1 and write
them to sheet 2. While this piece of code works most of the time, its
not dynamic enough to take into account the situation where the ratio
changes for every new 200 ttest it has to perform. For example, the
first workbook will have columns with the first 50 that is one group
and the second 50 in another, and the second work book will have
columns with the first 40 cells that is group one and the next 60 cells
in group two. I've tried

ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[K]C,sheet1!R[K+1]C:R[100]C,2,2)"


by inserting a variable into the column argument and changing k for
each new workbook, however, that does not work. Can someone please
suggest something?


cheers, and thanks ahead of time.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Trouble with passing a range into worksheet function in VBA


Hi, thanks for the suggestion but how should i intialized K. Do i
declare it as a long? Dim K as Long?

Setting K to a specific number does not seem to work

cheers, and thank you once again, and whoever may answer


On Jan 25, 4:38 pm, "Bob Phillips" wrote:
ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[" & K & "]C,sheet1!R[" & K &
"+1]C:R[100]C,2,2)"

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)

wrote in oglegroups.com...



------ Hi i am having a lot of trouble with the following piece of
code.


ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[50]C,sheet1!R[51]C:R[100]C,2,2)"


--- This code looks for the p value within the two groups of a single
column. There are 200 columns, and all the columns are arranged so that
the first 50 value belongs to one group and the second fifty values
belongs to the other. I am trying to write a macro to automate the
results of 200 individual ttest for 200 columns from sheet 1 and write
them to sheet 2. While this piece of code works most of the time, its
not dynamic enough to take into account the situation where the ratio
changes for every new 200 ttest it has to perform. For example, the
first workbook will have columns with the first 50 that is one group
and the second 50 in another, and the second work book will have
columns with the first 40 cells that is group one and the next 60 cells
in group two. I've tried


ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[K]C,sheet1!R[K+1]C:R[100]C,2,2)"


by inserting a variable into the column argument and changing k for
each new workbook, however, that does not work. Can someone please
suggest something?


cheers, and thanks ahead of time.- Hide quoted text -- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Trouble with passing a range into worksheet function in VBA

Yes it should be long.What does the second part mean?

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


wrote in message
oups.com...

Hi, thanks for the suggestion but how should i intialized K. Do i
declare it as a long? Dim K as Long?

Setting K to a specific number does not seem to work

cheers, and thank you once again, and whoever may answer


On Jan 25, 4:38 pm, "Bob Phillips" wrote:
ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[" & K & "]C,sheet1!R[" & K &
"+1]C:R[100]C,2,2)"

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)

wrote in
oglegroups.com...



------ Hi i am having a lot of trouble with the following piece of
code.


ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[50]C,sheet1!R[51]C:R[100]C,2,2)"


--- This code looks for the p value within the two groups of a single
column. There are 200 columns, and all the columns are arranged so that
the first 50 value belongs to one group and the second fifty values
belongs to the other. I am trying to write a macro to automate the
results of 200 individual ttest for 200 columns from sheet 1 and write
them to sheet 2. While this piece of code works most of the time, its
not dynamic enough to take into account the situation where the ratio
changes for every new 200 ttest it has to perform. For example, the
first workbook will have columns with the first 50 that is one group
and the second 50 in another, and the second work book will have
columns with the first 40 cells that is group one and the next 60 cells
in group two. I've tried


ActiveCell.FormulaR1C1 = _
"=TTEST(sheet1!RC:R[K]C,sheet1!R[K+1]C:R[100]C,2,2)"


by inserting a variable into the column argument and changing k for
each new workbook, however, that does not work. Can someone please
suggest something?


cheers, and thanks ahead of time.- Hide quoted text -- Show quoted
text -




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
Passing a range to a function David Bell Excel Programming 4 July 8th 06 08:32 PM
Passing a range to a function Isabelle[_2_] Excel Programming 1 January 23rd 06 10:24 PM
passing a range from another worksheet Mike O Excel Programming 4 July 21st 05 05:09 PM
Passing a range into a VBA function Floyd[_2_] Excel Programming 4 February 10th 05 01:29 AM
Passing range as an argument in a function Hari[_3_] Excel Programming 1 June 15th 04 02:41 AM


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