+ Reply to Thread
Results 1 to 7 of 7

Target Column with range

  1. #1
    Forum Contributor
    Join Date
    06-18-2015
    Location
    Milton Keynes
    MS-Off Ver
    2016
    Posts
    101

    Target Column with range

    Hi Guys,

    I've been asked to look at a document for a colleague.

    They have the following code:

    If Target.Column <> 6 Then
    Exit Sub 'Wrong column clicked on
    End If
    This stops the Macro if it wasn't run from column F.

    They want to add it to column G (7) How do I add it so that it says to the effect of

    If Target.Column <> 6 or 7 Then
    Exit Sub 'Wrong column clicked on
    End If

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Target Column with range

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: Target Column with range

    VBA is a bit "stupid" you need to tell him each time which column

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-18-2015
    Location
    Milton Keynes
    MS-Off Ver
    2016
    Posts
    101

    Re: Target Column with range

    Hi,

    They come back and told me that there needs to be a blank column in between so it would be 6 or 8.

    Unfortunatley Norie your solution wouldn't work in that case.

    Roel, I've tried yours, as seen below, but afterwards it is not working for either the original column or the new column


    Please Login or Register  to view this content.
    Could we do it as


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-18-2015
    Location
    Milton Keynes
    MS-Off Ver
    2016
    Posts
    101

    Re: Target Column with range

    obviously this would need to be something like if Target.Column =6 the do nothing else if Target column = 8 then do nothing else exit sub????

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Target Column with range

    Try this.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-18-2015
    Location
    Milton Keynes
    MS-Off Ver
    2016
    Posts
    101

    Re: Target Column with range

    Norie, I love you!!!!

    Been racking my head for hours!

    Works perfectly.

+ 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. Target.column for Data Validation would like to target some cells within column
    By iggypop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2017, 12:35 PM
  2. [SOLVED] If target cell is within table-column range.
    By DMA in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-21-2017, 12:53 AM
  3. [SOLVED] Lock Column Range using Target Reference
    By jdmara in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2015, 02:29 PM
  4. Replies: 5
    Last Post: 12-16-2014, 05:47 PM
  5. [SOLVED] Change(ByVal Target As Range) does not work when Target value changes
    By LeonvL in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-07-2013, 06:59 PM
  6. [SOLVED] Worksheet_Change(ByVal Target As Range) - set to only update when 3 target cells changed?
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2012, 06:40 PM
  7. Worksheet_CHange (ByVal Target as Range) when target is formula cell
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2012, 07:00 PM

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