Results 1 to 5 of 5

Selection Change macro to OFFSET

Threaded View

  1. #1
    Forum Contributor
    Join Date
    10-08-2019
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    326

    Selection Change macro to OFFSET

    Hello there,


    1. I'm trying to write a Selection Change macro to OFFSET the activecell to different cells (columns-Q,S,T) on each row based on the Text(s) contained in the user input cell in column-O. But my code doesn't seem to work. I attached a image below to illustrate my situation, with remarks that specify the criteria needed for how the specified keywords must be found in column-O, including the large/small caps or not they appear, in order for the OFFSET to move. Data in my workbook is from row 5 through to 5000.


    SelChngOFFSET.PNG


    This the last method i used in the most recent attempt at making the code to achieve above, all have failed. I also experimented with InStr & that failed miserably.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
       If Not Intersect(Target, Range("$O$5:$O$5000")) Is Nothing And Target.Value <> "" And Target.Cells.Count = 1 Then
    
        Range("$A$5:$A$5000").Calculate
    
         If Range("A" & Target.Row) = "REC" Then
          With ActiveCell
         .Offset(0, 4).Select
          End With
          
         ElseIf Range("A" & Target.Row) = "PWG" Then
          With ActiveCell
         .Offset(0, 2).Select
          End With
       
       End If
       
    End Sub

    2. The second problem I have is with column-A.
    I use the ISNUMBER function for column-A to return a short ID based on the text string in column-O, all is well till when the keywords in O is more than one keyword to locate. When the Description string in column-O is only 1 keyword to find, say the keyword to lookout for is only "RECYCLE", the ISNUMBER returns "REC" without any error. But i dont know how to use ISNUMBER to also lookout for & cover all the other possibilities shown in above image, ie. when ID should lookout for in the input cell strings that might contain 2 or more keywords simultaneously, if it meets that possibility it can't correctly return the correct ID.

    Here is my effort ISNUMBER example of the failed function for more than 1 keyword to return an ID, example when I need the cell in A5 to return "PWG" if O5 contains ALL 3 keywords "Return","to","via", but it anyhow returns "PWG" even if the user has only typed "Return" withoput typing "to" and "via"

    =IF(ISNUMBER(SEARCH({"Return","to","via"},O5)),"PWG",IF(ISNUMBER(SEARCH("Processing*",O5)),"PWG","")


    Hope someone can help me with above 2 issues,

    Stewart.
    Last edited by MannStewart; 06-07-2020 at 09:15 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro not firing upon selection change
    By cp41 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-23-2013, 03:25 PM
  2. [SOLVED] Macro to change shape/macro button colours based on selection
    By deanstein in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2013, 08:26 AM
  3. Selection change macro
    By alanb1976 in forum Excel General
    Replies: 7
    Last Post: 08-18-2011, 08:48 AM
  4. Problem with Selection find, offset, copy & paste Macro
    By MDResearcher in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-21-2011, 05:51 PM
  5. Macro for Selection Change
    By raghav.k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2011, 04:52 AM
  6. Macro to change dates in a selection
    By Slashy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2008, 07:48 PM
  7. run macro on selection change
    By Tony in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2006, 12:15 AM
  8. macro to change cells on change of selection
    By scottwilsonx in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-13-2005, 04:14 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