May 12, 2011 #1 wmbb Technical User Joined Jul 17, 2005 Messages 320 Location NL What is wrong in the code below defining a range? Code: x=2 rng = Sheet1.Range(Cells(x, 2), Cells(x, 30))
What is wrong in the code below defining a range? Code: x=2 rng = Sheet1.Range(Cells(x, 2), Cells(x, 30))
May 12, 2011 #2 S SkipVought Programmer Joined Dec 4, 2001 Messages 47,492 Location US Hi, How is rng declared? It should be declared as a RANGE. Then... Code: Dim rng as range, x as long x=2 [b][red]Set [/red][/b]rng = Sheet1.Range(Cells(x, 2), Cells(x, 30)) Is there a worksheet with a CodeName of Sheet1? Skip, Just traded in my old subtlety... for a NUANCE! Upvote 0 Downvote
Hi, How is rng declared? It should be declared as a RANGE. Then... Code: Dim rng as range, x as long x=2 [b][red]Set [/red][/b]rng = Sheet1.Range(Cells(x, 2), Cells(x, 30)) Is there a worksheet with a CodeName of Sheet1? Skip, Just traded in my old subtlety... for a NUANCE!
May 12, 2011 Thread starter #3 wmbb Technical User Joined Jul 17, 2005 Messages 320 Location NL He Skip, Thanks for your quick response. I just forgot "set" Now it works like it should. Thanks again. Upvote 0 Downvote
He Skip, Thanks for your quick response. I just forgot "set" Now it works like it should. Thanks again.
May 13, 2011 #4 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR For safety purpose I'd use full qualified objects: Set rng = Sheet1.Range([!]Sheet1.[/!]Cells(x, 2), [!]Sheet1.[/!]Cells(x, 30)) Hope This Helps, PH. FAQ219-2884 FAQ181-2886 Upvote 0 Downvote
For safety purpose I'd use full qualified objects: Set rng = Sheet1.Range([!]Sheet1.[/!]Cells(x, 2), [!]Sheet1.[/!]Cells(x, 30)) Hope This Helps, PH. FAQ219-2884 FAQ181-2886