Change the Caption of a Button error...

Alex Piotto

Board Regular
Joined
Jul 5, 2016
Messages
82
Office Version
  1. 2007
Platform
  1. Windows
Hi everybody.
I am trying to change the caption of a button using a value from a cell (named PERIODO).

But i get an error like:

Runtime error 1004
Unable to set the caption property of the Button Class


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("PERIODO")) Is Nothing Then

Buttons("Button 1").Caption = "Save As:" & vbNewLine & Sheets("RESUMO").Range("PERIODO") & vbNewLine & "and Clear"

End If

End Sub

Now, if i take out the last part, (& vbNewLine & "and Clear") it works...

What am i missing?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
That works for me, what is in the PERIODO cell?
 
Upvote 0
Hi Fluff, the cell contains a date manually inserted... like OUTUBRO 2020. But i noticed that if i insert shorter text it works... maybe is a bug...
Sometimes i get the error sometimes do not. If i write in portuguese there are more characters and it does not work.
 
Upvote 0
What version of Excel are you using?
 
Upvote 0
2007... still...
Now it seems to work but the carriage returns inside the button are too big and part of the caption is hidden
 
Upvote 0
In that case it sounds as though something has changed since 2007, as I cannot get the error you are getting.
If the text in the cell is too long, the caption simply doesn't update.
 
Upvote 0
Thanks for the quick answer. I may have to find another way. Tomorrow!
 
Upvote 0
Sorry I couldn't be of more help.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

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