Having issues with Index MATCH.

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
477
Office Version
  1. 365
Platform
  1. Windows
I use this function to split comment text to multiple rows:

Excel Formula:
Function GetComment(cl As Range) As Variant
   GetComment = Application.Transpose(Split(cl.Comment.Text, vbLf))
End Function


options1.png


I paste the comment from a cell on another sheet to cell B6. The comment text runs from A6:A11 using the code above. In G7 I have a formula that matches the value in A7 with data from row A on the Options sheet and returns the value from column B:


options2.png


Unfortunately, G7 will not populate. I figured it was some sort of text format issue so I tested it by copying A7 on the SendFloorRequest sheet (top) and pasting it on A11 on the Options sheet (bottom). It then worked correctly. Not sure what is causing this.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I did check for leading and trailing spaces and there weren't any.
 
Upvote 0
Well, now it appears that a trailing space IS causing my grief! Here's the code that creates the Comment:

VBA Code:
Private Sub cmdAddComment_Click()
On Error Resume Next
 Dim com As String
 com = OptionList.Text

    Dim vCellValue As Variant
    Dim sText As String
  
    vCellValue = ActiveCell.Value
    If IsNumeric(vCellValue) Then
        vCellValue = CDbl(vCellValue)
    End If
      
    sText = Application.UserName & ":" & vbCrLf
    sText = sText & com
  
    With ActiveCell
        .ClearComments
        With .AddComment
            .Text sText
            With .Shape
                .TextFrame.Characters(1, InStr(sText, ":")).Font.Bold = True
                .Width = 180
                .Height = 60
                With .TextFrame.Characters.Font
                   .Name = "Tahoma"
                   .Size = 12
                End With
                With .TextFrame
                   .AutoSize = True
                End With
            End With
        End With
        
        On Error GoTo 0
        
    End With
  
End Sub

Something in there is adding a space after each line of text and before the carriage return.
 
Upvote 0
Try using
VBA Code:
sText = Application.UserName & ":" & vbLf
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top