Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Query Table Problem

I have a sheet in a workbook that gets populated from SQL Server via
implemnting QueryTable. This part works great!

The problem is I have to apply or remove an exchange rate on the values in
the Query Table results sheet. When I loop through the rows and take the
values from a cell in a specific column and multiply it by the exchange rate
it takes forever... If I copy the results into another sheet and then run
the code it takes 2.5 minutes, but in the original sheet it takes over 3
hours. Anyone got any ideas on this? I tried deleting the query table, but
it had not effect. Here is my code:

Sub SetUnsetExchangeRate(strType As String)
Dim rowIndex As Integer, MaxRow As Integer, colFCLP As Integer, colCLP As
Integer
Dim colPriceBase As Integer, wsSource As Worksheet, iPct As Integer
Dim dblValue As Double, dblExchangeRate As Double, strFunction As String

Application.ScreenUpdating = False

Set wsSource = Worksheets("Products")
'Get the Exchange Rate
dblExchangeRate = Worksheets("Start").Range("ExchangeRate").Value
'Set the column numbers variables
colFCLP = 6
colCLP = 16
colPriceBase = 15
'Get the total number of rows loaded in Products page.
MaxRow = Worksheets("Products").Range("Productsloaded").

'Loop through rows of the used range and apply the exchange rate.
For rowIndex = 4 To MaxRow
'Select the FCLP cell to be changed.
dblValue = wsSource.Cells(rowIndex, colFCLP).Value
'Selection.Value
If strType = "Apply" Then
dblValue = dblValue * dblExchangeRate
Else
dblValue = dblValue / dblExchangeRate
End If
wsSource.Cells(rowIndex, colFCLP).Value = dblValue 'Selection.Value
= dblValue

'Select the CLP cell to be changed.
dblValue = wsSource.Cells(rowIndex, colCLP).Value
If strType = "Apply" Then
dblValue = dblValue * dblExchangeRate
Else
dblValue = dblValue / dblExchangeRate
End If
wsSource.Cells(rowIndex, colCLP).Value = dblValue

'Select the Price Base cell to be changed.
dblValue = wsSource.Cells(rowIndex, colPriceBase).Value
If strType = "Apply" Then
dblValue = dblValue * dblExchangeRate
Else
dblValue = dblValue / dblExchangeRate
End If
wsSource.Cells(rowIndex, colPriceBase).Value = dblValue

'Update Status Bar
iPct = rowIndex / (MaxRow / 100)
Application.StatusBar = "Processing Exchange Rate, this will take
several minutes..." & iPct & "% Complete."

Next rowIndex

'Reset Status bar
Application.StatusBar = False

Application.ScreenUpdating = True
End Sub


Thanks,
Sherry


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
Query problem Keith H[_2_] Excel Discussion (Misc queries) 2 December 16th 09 04:30 PM
Problem with Web Query Albert Excel Discussion (Misc queries) 0 August 19th 09 05:23 AM
Ms Query problem Janie Excel Discussion (Misc queries) 2 September 19th 06 07:25 PM
Problem with MS Query - can't edit query jarems Excel Discussion (Misc queries) 2 December 12th 05 09:42 AM
Query problem Will Excel Discussion (Misc queries) 2 November 21st 05 03:02 PM


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