View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Chart versus Work Sheet Code Failure

I got the code to run simply by adding

shPressure.select

at the start of the procedure.

So now it goes something like this...

Dim ActiveObject As Variant
Set ActiveObject = ActiveSheet
shPressure.Select
VBAProject.shPressure.Rows("6:7").Copy Destination:=shPressure.Range("A1")
xlrow = shControl.Cells(Rows.Count, "K").End(xlUp).Row
ActiveObject.Select

The ActiveObject stores the sheet that was originally selected prior to
running the code. It is a little ugly but it works. Why it won't work to
begin with is beyond me...

HTH

"Nigel" wrote:

Hi All
I have a problem when I update a workbook where I have selected (using sheet
tab not in code) a Chart sheet as opposed to a Work sheet.

If I select a Worksheet and run a procedure that updates a number of other
Worksheets everything is fine. If I have a Chart Sheet selected, then I get
an error, even though the code makes no specfic reference to the Chart.
Examples of the code that throw an error follow (shPressure and ShControl
are both worksheets)

The first refers to a work sheet (not chart), but if a chart is selected I
get Run-time error 13 Type Mismatch, the second Run-time error 1004 Method
'Rows' of object '_global' failed.

shPressure.Rows("6:7").Copy Destination:=shPressure.Range("A" & xFirstRow)

xlrow = shControl.Cells(Rows.Count, "K").End(xlUp).Row


--
Cheers
Nigel