Unable to set the Text property of the characters class

AndyGav86

New Member
Joined
Nov 17, 2022
Messages
33
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
Sub ClearContents1()

Sheet1.Range("A3:A6,B6,B8:B36,C8:C36,D8:D36").ClearContents

Sheet2.Range("B4:C6,D4,A11:D11,A16:C16,D21:D24,B30:C30,B34:C34,B39:C39,A44:B44,A46:B46,A50:B50,A52:B52,A57:D60,B64:B67,C65,C72:D76,E80:E86,E89,B90:B94,B96:B100,D90:D94,D96:D100,C104:D111,A113:D113").ClearContents

Sheet1.Shapes("TextBox 1").Select
Selection.Characters.Text = ""

Sheet2.Shapes("TextBox 3").Select
Selection.Characters.Text = ""

End Sub


How do i fix this error please?

It wont clear TextBox 1
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hello @AndyGav86

Try this:
VBA Code:
Sub ClearContents1()
  Application.ScreenUpdating = False
  Sheet1.Select
  Sheet1.Range("A3:A6,B6,B8:B36,C8:C36,D8:D36").ClearContents
  Sheet1.Shapes("TextBox 1").Select
  Selection.Characters.Text = ""
  
  Sheet2.Select
  Sheet2.Range("B4:C6,D4,A11:D11,A16:C16,D21:D24,B30:C30,B34:C34," & _
               "B39:C39,A44:B44,A46:B46,A50:B50,A52:B52,A57:D60," & _
               "B64:B67,C65,C72:D76,E80:E86,E89,B90:B94,B96:B100," & _
               "D90:D94,D96:D100,C104:D111,A113:D113").ClearContents
  Sheet2.Shapes("TextBox 3").Select
  Selection.Characters.Text = ""
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
You could also use
VBA Code:
Sheet1.Shapes("TextBox 1").TextFrame.Characters.Text = ""
without the need for selecting anything
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,120
Messages
6,128,948
Members
449,480
Latest member
yesitisasport

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