+ Reply to Thread
Results 1 to 2 of 2

Applying code to specific cells when using worksheet_change?

  1. #1
    Registered User
    Join Date
    08-13-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    1

    Applying code to specific cells when using worksheet_change?

    New here and to VBA, but want code where result only applies to a range of cells . I have the following code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Value = "" Then
    Target.Formula = "=iferror(vlookup(A15:a18,$A$21:$B$24,2,),0)"
    End If

    End Sub

    But i want it to apply to cells C14:C19 only. currently if any other cell is overwritten and deleted it returns this formula too.

    I hope this makes sense!

    David

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Applying code to specific cells when using worksheet_change?

    Hi
    Try changing your second code line as follows:

    If Not Application.Intersect(Target, Range("C14:C19")) Is Nothing Then

    Good luck
    Tony

+ 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. Replies: 0
    Last Post: 10-15-2012, 07:24 AM
  2. [SOLVED] Applying code only to visible cells
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2012, 11:07 AM
  3. Applying a specific functions over a range of cells
    By Rikolos in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-27-2010, 07:35 PM
  4. applying macro code to a range of cells
    By just-gal in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2009, 02:26 PM
  5. Applying colors to specific cells
    By encounter779 in forum Excel General
    Replies: 3
    Last Post: 02-09-2005, 10:04 AM

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