View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
havocdragon havocdragon is offline
external usenet poster
 
Posts: 75
Default Run-time error after calling a procedure

I am assuming 'j' is a defined variable? If so, you would need to make a
public statement. What happens is, if you dim and set j in this procedure and
then call insert spectrum, j's set data can be lost. Above all the subs in
your module, type something like 'Public j as variant'. Although make sure
that InsertSpectrum is in the same module, as sometimes even public dims wont
work across multiple modules.

"hmm" wrote:

Here is a segment of my code:

InsertSpectrum
ActiveSheet.Range(Cells(12 + j, 22), Cells(12 + j, 35)).Value = _
ActiveSheet.Range("V10:AI10").Value

where InsertSpectrum is another procedure in the same project.

The 2nd line does not execute; instead, I get an error "Run-time error
'1004': Method 'Cells' of object '_Global' failed". If I remove the call to
InsertSpectrum, the next line executes properly.

What can I check to correct the problem, so that the second line will run
after the procedure call?