+ Reply to Thread
Results 1 to 5 of 5

VBA across different sheets

  1. #1
    Registered User
    Join Date
    10-24-2017
    Location
    Aarhus, Denmark
    MS-Off Ver
    2016
    Posts
    15

    VBA across different sheets

    Hello Everyone
    As can be seen with below code it works partially as supposed to. The problem is that the lookup cell is located in another sheet, how can i incorporate that into the code? Furthermore, the red color should dissapear if the "code input" cell is empty. Lastly, the red color should be shown in the name cell if the user inputs an invalid code. (see excel sheet for example)

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Cell As Range

    Application.EnableEvents = False

    For Each Cell In Target
    If Cell.Column = 2 Then
    If WorksheetFunction.CountIf(Columns(6), Cell) > 0 Then
    Cell.Offset(0, 1) = Columns(6).Find(Cell, , xlValues, xlWhole).Offset(0, 1)
    Else
    Cell.Offset(0, 1).Interior.ColorIndex = 3
    End If
    End If
    Next Cell

    Application.EnableEvents = True

    End Sub
    Credit to Mrice for the current code

    Really hope someone can help!
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA across different sheets

    Try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    10-24-2017
    Location
    Aarhus, Denmark
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA across different sheets

    Hello xladept the code worked perfectly! Thank you for your assistance

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA across different sheets

    You're welcome!

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA across different sheets

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] Codes for Prevent users from adding sheets, deleting sheets, hiding/unhiding sheets
    By geniusufo007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2017, 11:57 PM
  2. Compare Sheets and Display the previous sheets column in current sheets
    By maddyrafi1987 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 05-09-2017, 04:03 AM
  3. Create New Sheets, Copy New Sheets & Name New Sheets - §8-O
    By Gtrtim112 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-26-2016, 10:58 PM
  4. Programming code : Sheets.Add After:=Sheets(Sheets.Count)
    By Blok , Robert in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2015, 05:00 AM
  5. Replies: 1
    Last Post: 10-04-2013, 04:21 AM
  6. Replies: 17
    Last Post: 02-01-2013, 12:20 PM
  7. Replies: 2
    Last Post: 01-18-2012, 05:08 AM

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