From: John Guillory on
To: OldDog
Re: Excel Range from variable
By: OldDog to microsoft.public.scripting.vbscript on Thu Apr 15 2010 11:36 am

> ws1.Range("C3:C" & row).Copy(ws2.Range("A2"))
> However if I try to change the row and column to a variable it does
> not work.
Try "Named Ranges", where you name the range of sells a meaningufl name....

--- Synchronet 3.15a-Win32 NewsLink 1.92
mlcgroup bbs - telnet://roachguts.com
From: Brian Kelly on
OldDog wrote:

> However if I try to change the row and column to a variable it does
> not work.
>
> I have tried:
>
> ws1.Range(.Cells(rRow & "," & rCol).Cells(row & "," &
> rCol)).Copy(ws2.Range("B2"))
>
> And this;
>
> ws1.Range(rRow & "," & rCol & ":" & row & "," &
> rCol).Copy(ws2.Range("D2"))
>
> Any ideas?

Use the cells property of the range object and use notation like cells(x,y)
where x and y are integers e.g ws1.Range.cells(1,1) see
http://www.anthony-vba.kefra.com/vba/vbabasic2.htm#Range_Object_and_Cells_Property
for examples

--
Brian Kelly
Home Page http://kellybk.com
Species Race http://speciesrace.com