LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Lookup help needed

How do I modify the receipt number so that it can loop through all the
receipt numbers in columnG of sheet1 and yield result.
------------------------------------------------------------------------------------
Option Explicit
Sub Testme()

Dim MstrWks As Worksheet
Dim StockNumWks As Worksheet
Dim FormRng As Range
Dim VLookUpAddr As String
Dim LastRow As Long
Dim i As Variant
Dim Receipt As Variant

Set MstrWks = Worksheets("sheet1")
Set StockNumWks = Worksheets("sheet2")

With MstrWks
LastRow = .Cells(.Rows.Count, "G").End(xlUp).Row
Set FormRng = .Range("P2:P" & LastRow)
End With


VLookUpAddr = StockNumWks.Range("C:F").Address(external:=True)


With FormRng
'turn calculation to manual before plopping in the formulas
Application.Calculation = xlManual
.Formula = "=vlookup(" & Receipt & "," & VLookUpAddr & ",
4,false)"
'back to automatic
Application.Calculation = xlAutomatic


'convert to values
.Copy
.PasteSpecial Paste:=xlPasteValues


'remove those marching ants/marquee
Application.CutCopyMode = False


'get rid of no match and empty cells that came back as 0's
.Replace what:="#n/a", replacement:="", _
lookat:=xlWhole, searchorder:=xlByRows, _
MatchCase:=False
.Replace what:="0", replacement:="", _
lookat:=xlWhole, searchorder:=xlByRows, _
MatchCase:=False
End With

End Sub

-------------------------
This is a modified of original.
 
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
Lookup help needed Guntars Excel Worksheet Functions 1 May 22nd 09 07:08 AM
Lookup help needed Guntars Excel Worksheet Functions 3 May 22nd 09 05:27 AM
Lookup value needed Deepak Excel Discussion (Misc queries) 3 July 6th 08 03:30 AM
lookup help needed [email protected] Excel Programming 2 April 16th 08 03:08 AM
Lookup help needed atran Excel Worksheet Functions 1 June 22nd 05 09:24 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"