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: 1
Default Please help.. VLookup Macro


I got it working a different way.. I put the VRM list in the same file
set it as hidden (in VBEditor), password protected the VBEditor an
used the following code to do what I wanted to do:

Sub VRMReplace()

Dim MyStr1 As String, MyStr2 As String
MyStr2 = ("mypassword") '*****This is the password
MyStr1 = InputBox("Please Enter Password")
If MyStr1 = MyStr2 Then

Dim cel As Range, rng1 As Range, rng2 As Range, rng3 As Range

Set rng1 = Worksheets("Venture").Range("A22:A58")
Set rng2 = Worksheets("VRM").Range("B1:C145")
Set rng3 = Worksheets("VRM").Range("B:B")
Set rng4 = Worksheets("Industrial Grain").Range("A22:A25")
Set rng5 = Worksheets("Receiving").Range("A8:A43")
Set rng6 = Worksheets("Manhours").Range("A24:A30")

For Each cel In rng1
If WorksheetFunction.CountIf(rng3, cel) 0 Then
cel = WorksheetFunction.VLookup(cel, rng2, 2, False)
Else
MsgBox "Product Code not found"
End If
Next

For Each cel In rng4
If WorksheetFunction.CountIf(rng3, cel) 0 Then
cel = WorksheetFunction.VLookup(cel, rng2, 2, False)
Else
MsgBox "Product Code not found"
End If
Next

For Each cel In rng5
If WorksheetFunction.CountIf(rng3, cel) 0 Then
cel = WorksheetFunction.VLookup(cel, rng2, 2, False)
Else
MsgBox "Product Code not found"
End If
Next

For Each cel In rng6
If WorksheetFunction.CountIf(rng3, cel) 0 Then
cel = WorksheetFunction.VLookup(cel, rng2, 2, False)
Else
MsgBox "Product Code not found"
End If
Next

ActiveWorkbook.PrintOut

ActiveWorkbook.Close False

Else
MsgBox ("Access Denied")
End If


End Su

--
richinlaf3
-----------------------------------------------------------------------
richinlaf31's Profile: http://www.excelforum.com/member.php...fo&userid=2584
View this thread: http://www.excelforum.com/showthread.php?threadid=39253

 
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
VLOOKUP Macro? blucajun Excel Worksheet Functions 3 June 30th 08 09:54 PM
VLOOKUP Macro? blucajun Excel Worksheet Functions 0 June 27th 08 10:23 PM
VLOOKUP in a macro?? chip_pyp Excel Discussion (Misc queries) 1 March 27th 06 09:40 PM
Please help.. VLookup Macro STEVE BELL Excel Programming 3 August 3rd 05 05:31 PM
VLOOKUP MACRO JOHN YOUNG Excel Programming 2 July 23rd 04 10:21 PM


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