Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Data table automation problem

I've created a piece of VBA code to refresh some data tables and then
do a copy-paste special on the result... reason being is there are 16
data tables in the workbook and it runs too slowly if they are
"active".

The code I've written works the first time it is run (i.e. for one data
table), however the second time I run the code I get the following
message:

Runtime error '-2147417848 (80010108)' Automation error The object
invoked has disconnected from its clients.

The code is below, the row that is creating the error is highlighted
with ***

Sub DataTableSetup(DT)
'This macro calculates re-calculates either select or all data tables
in the model. Individual data
'tables are selected by passing the number of the data table to the
function. All data tables are selected by passing
' "ALL" to the macro. The macro paste values of data table
calculations. This is to prevent the
' model from becoming unacceptably slow when data tables exist

Dim origsheet As String
Dim origrow As Integer
Dim origcol As Integer
Dim DTRName As String ' Data table area name
Dim DTIName As String ' Data table input name
Dim DTCPName As String ' Data table copy / paste area
Dim DTHCName As String ' Data table hardcode area
Dim calcstate As String

Dim i As Integer

' Marks the orginial excel location to allow orginal location to be
returned at the end of the macro
origsheet = ActiveSheet.Name
origrow = ActiveCell.Row
origcol = ActiveCell.Column

' Sets calculation state to manual to speed up macro
calcstate = Application.Calculation
Application.Calculation = xlCalculationManual

'Test to see if 1 or all data tables require updating
If DT = "All" Then
'Calculates all data tables

'Sheets("iMacros").Select 'selects macro sheet

'For i = 1 To Range("charge_sens_data").Rows.Count 'loops over
all data tables
'This part is not yet complete
'Next i

Else
'Calculates a select data table

i = DT

Sheets("iMacros").Select 'selects macro sheet

'Retrieves required variables
DTRName = ActiveSheet.Range("DataTableAreas").Cells(i, 2).Value
DTCPName = ActiveSheet.Range("DataTableAreas").Cells(i, 3).Value
DTIName = ActiveSheet.Range("DataTableAreas").Cells(i, 4).Value
DTHCName = ActiveSheet.Range("DataTableAreas").Cells(i, 5).Value

'Selects sensitivites sheet, sets up data table and calculates
value
Sheets("oSensitivities").Select
ActiveSheet.Range(DTRName).Select

Selection.Table RowInput:=Range(DTIName) ***** PROBLEM CODE
******

Application.Calculate
ActiveSheet.Range(DTCPName).Copy
ActiveSheet.Range(DTCPName).Select

'Pastes output to iMacroSheet
ActiveSheet.Range(DTRName).Copy

'Sheets("iMacros").Select
ActiveSheet.Range(DTHCName).Select

End If

Sheets(origsheet).Select
Cells(origrow, origcol).Select
Application.Calculation = calcstate
Application.ScreenUpdating = False

End Sub


Any help would be much appreciated!

Cheers,
Will

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Table Automation OdAwG Excel Discussion (Misc queries) 14 March 4th 07 07:33 PM
C# Automation problem Jamie Oglethorpe Excel Programming 4 May 31st 06 04:07 PM
C++ automation problem [email protected] Excel Programming 0 March 24th 06 05:48 PM
problem with pivot table automation using perl [email protected] Excel Programming 0 March 21st 06 08:33 PM
importing Word table data into Excel - solutions for automation Han Excel Programming 0 January 18th 06 11:27 PM


All times are GMT +1. The time now is 11:37 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"