Results 1 to 13 of 13

VBA Code for Wrapping Text for Multiple Results and Preventing a Sheet from Scrolling

Threaded View

  1. #11
    Registered User
    Join Date
    10-04-2017
    Location
    France
    MS-Off Ver
    2016
    Posts
    15

    Re: VBA Code for Wrapping Text for Multiple Results and Preventing a Sheet from Scrolling

    Hi everyone,
    I'd like to tag along on this great post. I've used a code found in another post in order to create an item selector based on a number of criteria.
    Each cell which is filled in is supposed to look in another sheet and return a number of possible options as a result.

    My problem is that not all possible results show up in the destination cell, as it seems that the returned value is the 1st one found anf then the search stops. Furthermore, I have the feeling that at some stage the search is not on anymore, as some search fields don't seem to be taken into account (C14:C19)

    I've attached the file and would very much appreciate any help I can get in order to understand what I'm doing wrong.
    Many thanks,

    Private Sub Worksheet_Change(ByVal Target As Range)


    If Not Intersect(Target, Range("C2:C19")) Is Nothing Then
    
        Dim i As Integer
        Dim ws As Worksheet
        Set ws = Sheets("Source")
        
        Dim match As Integer
        match = 0
        
        
        For i = 1 To 7
        
            If Range("C2").Value = ws.Cells(2, i).Value Or _
                Range("C3").Value = ws.Cells(3, i).Value Or _
                Range("C4").Value = ws.Cells(4, i).Value Or _
                Range("C5").Value = ws.Cells(5, i).Value Or _
                Range("C6").Value = ws.Cells(6, i).Value Or _
                Range("C7").Value = ws.Cells(7, i).Value Or _
                Range("C8").Value = ws.Cells(8, i).Value Or _
                Range("C9").Value = ws.Cells(9, i).Value Or _
                Range("C10").Value = ws.Cells(10, i).Value Or _
                Range("C11").Value = ws.Cells(11, i).Value Or _
                Range("C12").Value = ws.Cells(12, i).Value Or _
                Range("C14").Value = ws.Cells(14, i).Value Or _
                Range("C15").Value = ws.Cells(15, i).Value Or _
                Range("C16").Value = ws.Cells(16, i).Value Or _
                Range("C17").Value = ws.Cells(17, i).Value Or _
                Range("C18").Value = ws.Cells(18, i).Value Or _
                Range("C19").Value = ws.Cells(19, i).Value Then
        
                match = 1
                With Range("E15")
                    .Value = ws.Cells(1, i).Value
                    .Interior.Pattern = xlSolid
                    .Interior.Color = 65535
                    .WrapText = True
                    .Rows.AutoFit
                    .Font.Bold = True
                    .Font.Italic = False
                End With
                
                Exit For
            End If
        
        Next i
        
        If match = 0 Then
            With Range("E15")
                .Value = "*No matches*"
                .Interior.Pattern = xlNone
                .Font.Bold = False
                .Font.Italic = True
            End With
        End If
    
    End If
    
    
    
    
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA: Wrapping text and transversing text between nubers or given speific text
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-08-2015, 07:52 PM
  2. Preventing ComboBox' list to detach when scrolling
    By AstroZelda in forum Excel General
    Replies: 3
    Last Post: 06-01-2015, 04:42 AM
  3. Replies: 4
    Last Post: 01-20-2014, 10:52 AM
  4. Vba code help pulling data from one sheet and generate results to another sheet
    By OATMAS in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-21-2013, 11:45 AM
  5. Dear Users, please send me the code for scrolling text in status bar.
    By RAKESH MESHRAM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2012, 04:00 PM
  6. Replies: 1
    Last Post: 11-14-2007, 03:41 PM
  7. Preventing Info From Scrolling ... Possible ??
    By Mhz in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 08-13-2006, 06:50 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