#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Help


I have 2 workbooks that will be needed for this macro.

One is a simple list: column A = product code, column B = product
name

The second workbook is a forumula for our products, which uses only
product code so no one can get our formulas and take them.

Before we print this for internal use, we would like to convert the
product code to the product name by running a macro.

For example, I would like to search the formula workbook for the
product code and replace it with the product name. There are over 200
products, so doing a macro where I recorded replacing these
individually would take forever. Also, some of the product code are
very similar.. ie. VRM2004 VRM2004A VRM2004B. Obviously if you
search for VRM2004 it would change all of those, so it needs to be an
exact match with the product code in the first sheet.

Please help.


--
richinlaf31
------------------------------------------------------------------------
richinlaf31's Profile: http://www.excelforum.com/member.php...o&userid=25846
View this thread: http://www.excelforum.com/showthread...hreadid=392302

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Help


can anyone help me

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Macro Help

Have a look at the VLookup Function it should do everything you need


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Help


Thanks, but VLookup is a forumla. Can it be used in a macro also? I
don't want the product names to show up until a manager runs the macro
from their computer.

Any help would be greatly appreciated.


--
richinlaf31
------------------------------------------------------------------------
richinlaf31's Profile: http://www.excelforum.com/member.php...o&userid=25846
View this thread: http://www.excelforum.com/showthread...hreadid=392302

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro Help

You could actually do it as soon as the manager types in the product code.

I put the table on sheet2 in A:B and check for product codes in A3:A65536.

Rightclick on the worksheet tab that should have this behavior and select view
code. Paste this in:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myLookupRng As Range
Dim res As Variant

If Target.Cells.Count 1 Then Exit Sub 'one cell at a time

'headers in rows 1 and 2
If Intersect(Target, Me.Range("a3:a65536")) Is Nothing Then
Exit Sub
End If

Set myLookupRng = Worksheets("Sheet2").Range("a:b")

res = Application.VLookup(Target.Value, myLookupRng, 2, False)

Application.EnableEvents = False
If IsError(res) Then
Target.Value = "Invalid Code"
Else
Target.Value = res
End If
Application.EnableEvents = True

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

richinlaf31 wrote:

Thanks, but VLookup is a forumla. Can it be used in a macro also? I
don't want the product names to show up until a manager runs the macro
from their computer.

Any help would be greatly appreciated.

--
richinlaf31
------------------------------------------------------------------------
richinlaf31's Profile: http://www.excelforum.com/member.php...o&userid=25846
View this thread: http://www.excelforum.com/showthread...hreadid=392302


--

Dave Peterson


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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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