View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] JWai2006@gmail.com is offline
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.