Trouble with passing a range into worksheet function in VBA

J

JWai2006

------ 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.
 
B

Bob Phillips

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)
 
J

JWai2006

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


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)



------ 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 -
 
B

Bob Phillips

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

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


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


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)

message

------ 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 -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top