Run-time error '438': Object doesn't support this property or method

Wonnters

New Member
Joined
Feb 21, 2025
Messages
5
Office Version
  1. 365
  2. 2024
  3. 2016
Platform
  1. Windows
I don't understand why the above error pops up when I run this code.
VBA Code:
Sub Update_Labels()
'
' Update_Labels Macro
'

    Dim rStart As RANGE
    Dim shp As Shape
    Dim sFind As String
    Dim sTemp As String
    
    RANGE("A1").Select
    Set rStart = ActiveCell
    'search for textboxes
    For x = 0 To (59)
        sFind = "Bulb" & RANGE("L" & 164 + x) & " "
        If RANGE("O" & 164 + x) = True Then
            For Each oTextBox In ActiveSheet.TextBoxes
                shp.Select
                sTemp = shp.TextFrame.Characters.Text
                On Error Resume Next
                If InStr(LCase(sTemp), LCase(sFind)) <> 0 Then
                    oTextBox.Select
                    Selection.Text = "Bulb" & RANGE("L" & 164 + x) & " " & vbCrLf & RANGE("M" & 164 + x) & vbCrLf & RANGE("N" & 164 + x)
                End If
            Next
        End If
    Next x
    RANGE("A1").Select

'
End Sub
This code worked in another work sheet so I have no idea why it's not working here. The only thing I changed is the inner for lop. On the sheet that worked the oTextBox was shp defined as a shape and Texboxes was Shapes. But I can't do that in the current worksheet as there are charts and i don't want to check charts.
 
Try this :
VBA Code:
Sub Update_Labels()
Dim shp As Shape
Dim sFind As String
Dim sTemp As String
Dim x%

For x = 0 To 59
    sFind = "Bulb" & Range("L" & 164 + x).Value & " "
    If Range("O" & 164 + x).Value = True Then
        For Each shp In ActiveSheet.Shapes
            If shp.Type = msoTextBox Then
                sTemp = shp.TextFrame.Characters.Text
                If InStr(LCase(sTemp), LCase(sFind)) <> 0 Then _
                    shp.TextFrame.Characters.Text = "Bulb" & _
                    Range("L" & 164 + x).Value & " " & vbCrLf & _
                    Range("M" & 164 + x).Value & vbCrLf & _
                    Range("N" & 164 + x).Value
            End If
        Next shp
    End If
Next x
Range("A1").Select
End Sub
 
Upvote 0

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