PDA

View Full Version : help speed vba code



CCkfm2000
07-04-2007, 06:46 AM
Many thanks for looking at this problem

I need to speed this vba code.

Original thread http://www.vbaexpress.com/forum/showthread.php?t=9583

Thanks again

Option Explicit
Dim InvenA As Integer
Dim InvenB As Integer
Dim InvenC As Integer
Sub Inventory()
Do
InventoryABC
lookupInvenoryinfo
Do While InvenA = InvenB
InventoryABC
lookupInvenoryinfo
Exit Do
Loop
Loop Until InvenA = InvenB
End Sub
Sub lookupInvenoryinfo()
Sheets("LANE QUANTITY").Select
InvenA = ActiveSheet.Range("bx68")
InvenB = ActiveSheet.Range("bx69")
InvenC = ActiveSheet.Range("bx70")
End Sub
Sub InventoryABC()
Sheets("Inven1").Select
InventoryA
Sheets("Inven2").Select
InventoryB
Sheets("Inven3").Select
InventoryC
Sheets("LANE QUANTITY").Select
lookupInvenoryinfo
If InvenA < InvenB Then
InventoryA
End If
If InvenA < InvenC Then
InventoryA
End If
Sheets("LANE QUANTITY").Select
lookupInvenoryinfo
If InvenB < InvenA Then
InventoryB
End If
If InvenB < InvenC Then
InventoryB
End If
Sheets("LANE QUANTITY").Select
lookupInvenoryinfo
If InvenC < InvenA Then
InventoryC
End If
If InvenC < InvenB Then
InventoryC
End If
Sheets("LANE QUANTITY").Select
End Sub
Sub InventoryA()
Sheets("Inven1").Select
Range("A2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
End Sub
Sub InventoryB()
Sheets("Inven2").Select
Range("A2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
End Sub
Sub InventoryC()
Sheets("Inven3").Select
Range("A2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
End Sub

Bob Phillips
07-04-2007, 07:04 AM
This might help




Option Explicit
Dim InvenA As Integer
Dim InvenB As Integer
Dim InvenC As Integer
Sub Inventory()
Do
InventoryABC
lookupInvenoryinfo
Do While InvenA = InvenB
InventoryABC
lookupInvenoryinfo
Exit Do
Loop
Loop Until InvenA = InvenB
End Sub
Sub lookupInvenoryinfo()
With Sheets("LANE QUANTITY")
InvenA = .Range("bx68").Value
InvenB = .Range("bx69").Value
InvenC = .Range("bx70").Value
End With
End Sub
Sub InventoryABC()
InventoryA
InventoryB
InventoryC
lookupInvenoryinfo
If InvenA < InvenB Then
InventoryA
End If
If InvenA < InvenC Then
InventoryA
End If
lookupInvenoryinfo
If InvenB < InvenA Then
InventoryB
End If
If InvenB < InvenC Then
InventoryB
End If
lookupInvenoryinfo
If InvenC < InvenA Then
InventoryC
End If
If InvenC < InvenB Then
InventoryC
End If
End Sub
Sub InventoryA()
Sheets("Inven1").Range("A2").QueryTable.Refresh BackgroundQuery:=False
End Sub
Sub InventoryB()
Sheets("Inven2").Range("A2").QueryTable.Refresh BackgroundQuery:=False
End Sub
Sub InventoryC()
Sheets("Inven3").Range("A2").QueryTable.Refresh BackgroundQuery:=False
End Sub

CCkfm2000
07-04-2007, 08:04 AM
thanks xld much better with your version.