+ Reply to Thread
Results 1 to 3 of 3

VBA Validation.InputMessage Help

Hybrid View

asaysamone VBA Validation.InputMessage... 05-24-2022, 12:21 PM
Richard Buttrey Re: VBA... 05-24-2022, 12:33 PM
asaysamone Re: VBA... 05-26-2022, 02:56 PM
  1. #1
    Registered User
    Join Date
    05-22-2022
    Location
    USA
    MS-Off Ver
    2010
    Posts
    2

    VBA Validation.InputMessage Help

    I'm trying to dynamically generate a hover InputMessage but I'm struggling because I keep getting a "Run-time error 1004: Application-defined or Object-defined error"

    I have a "player sheet" and a "bracket sheet". On the player sheet, the first column has a team name and the second column has players in it as one cell. When I generate the bracket sheet dynamically, I'm using the team names. When this is being created, I want to also generate a hover InputMessage that will show the second players name on that team when I hover over it.

    I've tried

    Worksheets("bracket sheet").Range("B1").Validation.InputMessage = Worksheets("player sheet").Cells(2, "A").value
    I get the above error when doing this

    When I remove Worksheets("bracket sheet") and just do Range("B1").Validation.InputMessage, the InputMessage does generate as a Hover but on the player sheet in the correct cell. I need it to be on the bracket sheet. Help?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Validation.InputMessage Help

    Please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.

    Show a before and after situation with manually calculated results, explaining which information is data and which is results, and if it's not blindingly obvious how you have arrived at your results some explanatory notes as well.

    To upload a file click the Go Advanced button at the foot of your post, look underneath the post area for the Manage Attachments section and take it from there.

    I'm struggling to understand what YOU mean by a 'hover input message'.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    05-22-2022
    Location
    USA
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA Validation.InputMessage Help

    Here's a more condense version of what I'm trying to do with just one sheet. I have a method that returns a set of ranges and I just want to loop thru the ranges and set the Validation.InputMessage to a value. In this case the text "Please work". It loops thru the first time fine but the second time, I get an error.

    Private Sub GenHoverText_Click()
         Dim LastRow As Integer
         Dim SearchRange As Range, SearchResults As Range, rng As Range
        
         LastRow = activeSheet.UsedRange.row - 1 + _
                 activeSheet.UsedRange.Rows.Count
             
         Set SearchRange = Worksheets("Sheet1").Range("A3:I20")
         Set SearchResults = FindAll(SearchRange, "Search Value")
        
         If SearchResults Is Nothing Then
            'No match found
         Else
             For Each rng In SearchResults
                 Dim col, row As String
                
                 col = rng.Column
                 row = rng.row
                
                 rng.Validation.InputMessage = "Please work"
             Next rng
         End If
     End Sub
    Function FindAll(rng As Range, What As Variant, Optional LookIn As XlFindLookIn = xlValues, Optional LookAt As XlLookAt = xlWhole, Optional SearchOrder As XlSearchOrder = xlByColumns, Optional SearchDirection As XlSearchDirection = xlNext, Optional MatchCase As Boolean = False, Optional MatchByte As Boolean = False, Optional SearchFormat As Boolean = False) As Range
        Dim SearchResult As Range
        Dim firstMatch As String
        With rng
            Set SearchResult = .Find(What, , LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)
            If Not SearchResult Is Nothing Then
                firstMatch = SearchResult.Address
                Do
                    If FindAll Is Nothing Then
                        Set FindAll = SearchResult
                    Else
                        Set FindAll = Union(FindAll, SearchResult)
                    End If
                    Set SearchResult = .FindNext(SearchResult)
                Loop While Not SearchResult Is Nothing And SearchResult.Address <> firstMatch
            End If
        End With
    End Function
    Last edited by asaysamone; 05-26-2022 at 03:13 PM.

+ 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: 4
    Last Post: 05-18-2017, 04:27 AM
  2. update data validation sources if validation values change
    By mauler69 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2016, 05:10 PM
  3. [SOLVED] Add inputmessage without removing existing data validation
    By MrsAlice in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2012, 08:37 PM
  4. Check if a cell has Validation.InputMessage
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2010, 05:12 AM
  5. validation rules not working when someone copy paste data on validation cell
    By jthakrar in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-17-2010, 03:36 AM
  6. data validation-Can the source of the validation criteria be dfrom a different sheet?
    By yael pinkert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2009, 04:28 AM
  7. Validation inputmessage multilines
    By itarnak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-13-2005, 10:05 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