Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Change to Code

Pedro,

Use the Set statement to set the variables to range objects. E.g.,

SET fstRange = Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SET SndRange = Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pedro" wrote in message
...
Hi
What change should I made to the following code to work

fstRange =

Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SndRange =

Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))
strCorr =

Application.WorksheetFunction.Correl(fstRange,
SndRange)

Thanks
Pedro




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Change to Code

I already tried it but it seems give an error because of different
worksheets



"Chip Pearson" wrote in message
...
Pedro,

Use the Set statement to set the variables to range objects. E.g.,

SET fstRange = Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SET SndRange = Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pedro" wrote in message
...
Hi
What change should I made to the following code to work

fstRange =

Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SndRange =

Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))
strCorr =

Application.WorksheetFunction.Correl(fstRange,
SndRange)

Thanks
Pedro






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Change to Code

Thanks Chip
I already try that one but when I add the code
Application.WorksheetFunction.Correl(fstRange,SndR ange)
it will consider the range of the active worksheet and not those two in the
two ranges

Do you know how to solve it?
Thanks for your help

Best Regards,
PEdro



"Chip Pearson" wrote in message
...
Pedro,

Try the following:

With Worksheets(strSheet1)
Set fstRange = .Range(.Cells(RIndex2 - 35, CIndex2), _
.Cells(RIndex2, CIndex2))
End With
With Worksheets(strSheet)
Set SndRange = .Range(.Cells(RIndex2 - 35, CIndex3), _
.Cells(RIndex2, CIndex3))
End With

Note the periods preceding "Range" and "Cells".

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pedro" wrote in message
...
I already tried it but it seems give an error because of

different
worksheets



"Chip Pearson" wrote in message
...
Pedro,

Use the Set statement to set the variables to range objects.

E.g.,

SET fstRange = Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SET SndRange = Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pedro" wrote in message
...
Hi
What change should I made to the following code to work

fstRange =
Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SndRange =
Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))
strCorr =
Application.WorksheetFunction.Correl(fstRange,
SndRange)

Thanks
Pedro










  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Change to Code

Thanks Chip
Now it has worked

Regards
Pedro



"Pedro" wrote in message
...
Thanks Chip
I already try that one but when I add the code
Application.WorksheetFunction.Correl(fstRange,SndR ange)
it will consider the range of the active worksheet and not those two in

the
two ranges

Do you know how to solve it?
Thanks for your help

Best Regards,
PEdro



"Chip Pearson" wrote in message
...
Pedro,

Try the following:

With Worksheets(strSheet1)
Set fstRange = .Range(.Cells(RIndex2 - 35, CIndex2), _
.Cells(RIndex2, CIndex2))
End With
With Worksheets(strSheet)
Set SndRange = .Range(.Cells(RIndex2 - 35, CIndex3), _
.Cells(RIndex2, CIndex3))
End With

Note the periods preceding "Range" and "Cells".

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pedro" wrote in message
...
I already tried it but it seems give an error because of

different
worksheets



"Chip Pearson" wrote in message
...
Pedro,

Use the Set statement to set the variables to range objects.

E.g.,

SET fstRange = Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SET SndRange = Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pedro" wrote in message
...
Hi
What change should I made to the following code to work

fstRange =
Worksheets(strSheet1).Range(Cells(RIndex2 - 35,
CIndex2), Cells(RIndex2, CIndex2))
SndRange =
Worksheets(strSheet).Range(Cells(RIndex2 - 35,
CIndex3), Cells(RIndex2, CIndex3))
strCorr =
Application.WorksheetFunction.Correl(fstRange,
SndRange)

Thanks
Pedro














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
How do I change this code? OrlaLynch Excel Discussion (Misc queries) 1 June 11th 08 03:06 PM
change forecolor with code Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 2 November 29th 07 05:24 PM
VBA Code to Change the Tab Name Michael in Texas Excel Discussion (Misc queries) 1 March 28th 07 03:07 AM
VBA Code to Change the Tab Name Gary''s Student Excel Discussion (Misc queries) 0 March 28th 07 12:05 AM
combo box on change code frendabrenda1 Excel Discussion (Misc queries) 0 April 10th 06 04:21 PM


All times are GMT +1. The time now is 11:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"