So my VBA code works fine when I have the file saved on my computer but when I go to post it on sharepoint and share the excel file the vba code stops working. The text box pops up when select a cell in column C or D but then the textbox just stays on the screen and displays only the message from column D not from column C (I have two different messages identified for each column). Is there a modification to make the code work? I used the following code:
Public Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strTitle As String
Dim strMsg As String
Dim sTemp As Shape
Dim lDVType As Long
Dim ws As Worksheet
Application.EnableEvents = False
Set ws = ActiveSheet
Set sTemp = ws.Shapes("txtInputMsg")
On Error Resume Next
lDVType = 0
lDVType = Target.Validation.Type
On Error GoTo errHandler
If lDVType = 0 Then
sTemp.TextFrame.Characters.Text = ""
sTemp.Visible = msoFalse
Else
If Target.Validation.InputTitle <> "" Or _
Target.Validation.InputMessage <> "" Then
strTitle = Target.Validation.InputTitle & Chr(10)
strMsg = Target.Validation.InputMessage
With sTemp
'<<<<<<<<<<<< new code
.Left = Target.Left + 65 'adjust to suit
.Top = Target.Offset(3.1, 0).Top
'end of new code >>>>>>>>>>>>
With .TextFrame
.Characters.Text = strTitle & strMsg
.Characters.Font.Bold = False
.Characters(1, Len(strTitle)).Font.Bold = True
End With
End With
sTemp.Visible = msoTrue
Else
sTemp.TextFrame.Characters.Text = ""
sTemp.Visible = msoFalse
End If
End If
errHandler:
Application.EnableEvents = True
End Sub
Bookmarks