rename from control button name(name property) in excel vba

Viewed 1805

I have used a vba code to add a new row with from control button in column A.

the code is working fine but has a small issue.

I am trying to change button name property during copy but I dont know how to do it ?

For example, I am copying a button with name "validate", when it will be copied to next row I want to change the Name property (not the button text) of the button to "validate1".

can you please let me know how to do it ?

Dim Lr As Integer
Dim newLr As Integer
Dim lim, rng, sht, btn As String

Lr = Range("B" & Rows.Count).End(xlUp).Row 'Searching last row in column A
newLr = Lr + 1
lim = "B" & newLr & ":" + "D" & newLr
rng = "A" & newLr
Rows(Lr).Copy
Rows(newLr).Insert
'Range(lim).ClearContents
sht = ActiveSheet.Name
btn = "validate" & newLr
    Application.ScreenUpdating = False
    Sheets(sht).Shapes("validate").Copy
    Sheets(sht).Activate
    Sheets(sht).Range(rng).Select
    Sheets(sht).Paste
    Sheets(sht).Shapes("validate").Select
    Selection.Characters.Text = btn
    Application.ScreenUpdating = True

Image link: https://ibb.co/c0rFfv

3 Answers
Related