+ Reply to Thread
Results 1 to 2 of 2

Index match based on code with formatting intact

Hybrid View

  1. #1
    Registered User
    Join Date
    04-05-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    78

    Index match based on code with formatting intact

    I have “MASTER” datasheet with Item_Code , Description and Unit. When I type Item_Code in “EST” sheet, the corresponding Description and Unit against the code in “MASTER” should appear in EST sheet. The formatting as in MASTER sheet should be preserved in EST sheet also. I used the code but to no avail. Kindly guide


    Private Sub Worksheet_Change(ByVal Target As Range)
       Dim Fnd As Range
       Dim NotFnd As Boolean
       Dim Ws As Worksheet
       NotFnd = False
       If Target.CountLarge > 3 Then Exit Sub
       If Not Target.Column = 4 Then Exit Sub
    Application.EnableEvents = False
       For Each Ws In Worksheets
       If Not Ws.Name = "EST" Then
       Set Fnd = Ws.Columns(2).Find(Target.Value, , xlValues, xlWhole, , , False, , False)
       If Not Fnd Is Nothing Then
       NotFnd = True
       Fnd.Offset(, 1).Copy Target.Offset(, 4)
       Fnd.Offset(, 2).Copy Target.Offset(, 5)
       Exit For
       End If
       End If
       Next Ws
       If Not NotFnd Then MsgBox Target.Value & "not found"
    Application.EnableEvents = True
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,860

    Re: Index match based on code with formatting intact

    Copy and paste this macro into the worksheet code module. Do the following: right click the ESP tab name and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter an Item Code in column C and press the RETURN key.

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Intersect(Target, Range("C:C")) Is Nothing Then Exit Sub
        Dim ItemCode As Range
        Set ItemCode = Sheets("MASTER").Range("B:B").Find(Target, LookIn:=xlValues, lookat:=xlWhole)
        If Not ItemCode Is Nothing Then
            ItemCode.Offset(0, 1).Resize(, 2).Copy Target.Offset(0, 4)
        Else
            MsgBox ("Item Code not found.")
        End If
    End Sub
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Code for Index/Match/Match to input into excel based on 2 criteria inside form
    By Carl Fisher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2017, 12:11 PM
  2. Replies: 2
    Last Post: 05-24-2016, 08:10 PM
  3. Conditional formatting with INDEX MATCH MATCH
    By jawebb in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-28-2016, 05:01 AM
  4. Formatting with INDEX MATCH MATCH Problem
    By SwissExcel in forum Excel General
    Replies: 1
    Last Post: 07-22-2015, 07:40 AM
  5. Simple solution. Criteria based conditional formatting. (Index match) HELP!
    By omni13 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-18-2013, 12:11 PM
  6. [SOLVED] Conditional formatting based on VLOOKUP/INDEX:MATCH
    By strud in forum Excel General
    Replies: 2
    Last Post: 06-13-2013, 07:02 AM
  7. Combining with formatting intact
    By rkmase in forum Excel General
    Replies: 1
    Last Post: 12-12-2006, 12:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1