Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Look up & past value

Hi all, i was kindly helped by Tom with the code below & the Progress
bar code. It works really great on small worksheets up to 5,000 rows,
however i processed a worksheet with up 15,000 rows of information and
it took ages,(3 1/2 mins), at times they can be 60,000 rows long !!!.
Yes the counter makes a difference but not really anything to moan
about. Is there anyway that this can be sped up or would it be quicker
to copy the entire column from one workbook to the other, of Variable
names ?


Sub Lookups()

Dim myLookUpRng As Range
Dim i As Long
Dim NumRows As Long
Dim LastRow As Long
Range("D4").Select
With Workbooks(SuppFileNameC).Worksheets(SheetName)
Set myLookUpRng = .Range("D:N")
End With
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
' MsgBox "This Recon has : " & LastRow & " Rows of data - start"
NumRows = LastRow - 3
For i = 4 To LastRow
Cells(i, "L").Value = Application.VLookUp(Cells(i, "D").Value, _
myLookUpRng, 9, 0)
Cells(i, "L").Value = Cells(i, "L").Value
With Cells(i, "L")
.Font.ColorIndex = 3
.Font.Bold = True
End With
Cells(i, "M").Value = Application.VLookUp(Cells(i, "D").Value, _
myLookUpRng, 10, 0)
Cells(i, "M").Value = Cells(i, "M").Value
UpdateProgressV (i - 3) / NumRows
Next i
Range("A4").Select
On Error Resume Next
CloseForm2
End Sub


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Look up & past value

Try this:

Sub LookupsAA()

Dim myLookUpRng As Range
Dim i As Long
Dim NumRows As Long
Dim LastRow As Long
Range("D4").Select
With Workbooks(SuppFileNameC).Worksheets(SheetName)
Set myLookUpRng = .Range("D:N")
End With
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
' MsgBox "This Recon has : " & LastRow & " Rows of data - start"
NumRows = LastRow - 3
With Cells(4,L).Resize(NumRows)
.Formula = "=Vlookup(D4," & _
myLookupRng.Address(1,1,xlA1,True) & ",9,0)"
.Value = .Value
End With
With Cells(4,M).Resize(NumRows)
.Formula = "=Vlookup(D4," & _
myLookupRng.Address(1,1,xlA1,True) & ",10,0)"
.Value = .Value
End with
With Cells(4,"L").Resize(NumRows)
.Font.ColorIndex = 3
.Font.bold = True
End With
Range("A4").Select
CloseForm2
End Sub

--
Regards,
Tom Ogilvy

"Les Stout" wrote in message
...
Hi all, i was kindly helped by Tom with the code below & the Progress
bar code. It works really great on small worksheets up to 5,000 rows,
however i processed a worksheet with up 15,000 rows of information and
it took ages,(3 1/2 mins), at times they can be 60,000 rows long !!!.
Yes the counter makes a difference but not really anything to moan
about. Is there anyway that this can be sped up or would it be quicker
to copy the entire column from one workbook to the other, of Variable
names ?


Sub Lookups()

Dim myLookUpRng As Range
Dim i As Long
Dim NumRows As Long
Dim LastRow As Long
Range("D4").Select
With Workbooks(SuppFileNameC).Worksheets(SheetName)
Set myLookUpRng = .Range("D:N")
End With
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
' MsgBox "This Recon has : " & LastRow & " Rows of data - start"
NumRows = LastRow - 3
For i = 4 To LastRow
Cells(i, "L").Value = Application.VLookUp(Cells(i, "D").Value, _
myLookUpRng, 9, 0)
Cells(i, "L").Value = Cells(i, "L").Value
With Cells(i, "L")
.Font.ColorIndex = 3
.Font.Bold = True
End With
Cells(i, "M").Value = Application.VLookUp(Cells(i, "D").Value, _
myLookUpRng, 10, 0)
Cells(i, "M").Value = Cells(i, "M").Value
UpdateProgressV (i - 3) / NumRows
Next i
Range("A4").Select
On Error Resume Next
CloseForm2
End Sub


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Look up & past value

Thanks Tom, it is home time here and the frosty is calling... will be in
tomorrow so will try it then..

Great weekend and thanks again for all the help.

best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
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
Past due function nannybears Excel Worksheet Functions 5 June 10th 09 01:14 AM
past special geb Excel Worksheet Functions 2 June 2nd 09 03:39 AM
Past Due - Due Dates melarmor Excel Worksheet Functions 3 June 2nd 05 06:13 AM
Past formula to the end Duncan J Excel Programming 1 February 27th 04 05:36 PM


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