#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help

I'm new to VBA and I can't seem to get this to work:
Set testrange = ActiveWorkbook.Worksheets("Mysheet").Range(Cells(3 , 8),
Cells(300, 8))

it returns a 1004 error..

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default help

Hi

Use this

With Worksheets("Mysheet")
Set testrange = .Range(.Cells(3, 8), .Cells(300, 8))
End With

In your code cells use the cells in the activesheet and not in the sheet Mysheet
see the dots before Cells now so it use the cells on the sheet Mysheet

You can also use

Set testrange = Worksheets("Mysheet").Range(Worksheets("Mysheet"). Cells(3, 8), Worksheets("Mysheet").Cells(300, 8))



--
Regards Ron de Bruin
http://www.rondebruin.nl



"jutes.g" wrote in message oups.com...
I'm new to VBA and I can't seem to get this to work:
Set testrange = ActiveWorkbook.Worksheets("Mysheet").Range(Cells(3 , 8),
Cells(300, 8))

it returns a 1004 error..



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



All times are GMT +1. The time now is 03:52 AM.

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

About Us

"It's about Microsoft Excel"