+ Reply to Thread
Results 1 to 5 of 5

Use macro code in only one column

  1. #1
    Registered User
    Join Date
    10-05-2012
    Location
    Liverpool
    MS-Off Ver
    Excel 2010
    Posts
    7

    Use macro code in only one column

    Hey guys, first post.

    I need help. I'm using this code in my work:

    Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngDV As Range
    If Target.Count > 1 Then GoTo exitHandler
    Application.EnableEvents = False

    On Error Resume Next
    Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
    On Error GoTo exitHandler
    If rngDV Is Nothing Then GoTo exitHandler
    If Intersect(Target, rngDV) Is Nothing Then
    'do nothing
    Else
    If Target.Value = "" Then GoTo exitHandler
    If Target.Offset(0, 1).Value = "" Then
    Target.Offset(0, 1).Value = Target.Value
    Else
    Target.Offset(0, 1).Value = _
    Target.Offset(0, 1).Value _
    & Chr(10) & Target.Value
    End If
    End If

    exitHandler:
    Application.EnableEvents = True
    End Sub

    I need that to only work in column D

    Thanks guys

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,596

    Re: Use macro code in only one column

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-05-2012
    Location
    Liverpool
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Use macro code in only one column

    Quote Originally Posted by TMShucks View Post
    Please Login or Register  to view this content.

    Regards, TMS
    Thanks mate

  4. #4
    Registered User
    Join Date
    10-05-2012
    Location
    Liverpool
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Use macro code in only one column

    Quote Originally Posted by TMShucks View Post
    Please Login or Register  to view this content.

    Regards, TMS
    Where would i add this?

    -Cheers

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,596

    Re: Use macro code in only one column

    After the Dim.

    Regards, TMS

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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