Difficulty with a range object

Odin

New Member
Joined
Jul 13, 2006
Messages
32
Hi Folks,

I am having some problems with a range object that I created. I am trying to assign a set of values from an array to this range object. Before assigning these values, I increment iRowCount by one to move the range one row lower in the spreadsheet. When I use the following code with the Select statement, it works fine:

Worksheets("EvtData").Select
Set EvtCurrentRow = Range(Cells(iRowCount, 1), Cells(iRowCount, EvtCols))

So here is the problem. Since the EvtData sheet may be “very hidden”, I cannot use the Select statement. I tried doing it as shown below, however I get a Runtime Error 1004 “Application-defined or object-defined error”.

Set EvtCurrentRow = Worksheets("EvtData").Range(Cells(iRowCount, 1), Cells(iRowCount, EvtCols))

Does anyone know how to get around this? Many thanks for your help.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Mark

Try this.
Code:
With Worksheets("EvtData")
 Set EvtCurrentRow = .Range(.Cells(iRowCount, 1), .Cells(iRowCount, EvtCols))
 
Upvote 0
Hi,

I just tried it


With Worksheets("EvtData")
Set EvtCurrentRow = .Range(Cells(iRowCount, 1), Cells(iRowCount, EvtCols))
EvtCurrentRow.Value = EvtTempArray
End With


and I still get the same error at the same place. Thanks for your help anyway.
 
Upvote 0
Mark

You didn't actually try what I posted.:)

The crucial thing is the dot qualifier . before Cells.

Without that VBA will assume you are referring to Cells on the currently active sheet, not your hidden sheet.
 
Upvote 0
You were absolutely right! It worked! It is amazing what a couple of well placed dots can do.

Thanks for following up again and bringing it to my attention. Much appreciated.
 
Upvote 0
You were absoutely right! It worked! It is amazing what a couple of well placed dots can do.

Thanks for following up again and bringing it to my attention. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,222,011
Messages
6,163,385
Members
451,834
Latest member
tomtownson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top