How to get the button name:LineRowNumber, where RowNumber varies for different buttons.

luolovepi

Board Regular
Joined
Jun 9, 2011
Messages
116
My worksheet contains a list of buttons at each row. The name of button is like: for example, row 15 has a button named Line15; row 16 has a button called Line16.

I have a sub to transfer the row information to another worksheet only if the data in that row is integrate.

And I want to hide the buttons of the rows whose data have been tranfered.

I try to get the button name as below, but it is wrong. How to get the button name in a for loop where row number is the increment variable?
Code:
Dim buttonName As String
buttonName = "Line" & Row
buttonName.Visible = False
my full sub code is as follows:
Code:
Private Sub SubmitAll_Click()
    Dim Row As Integer
    For Row = 15 To 36
        Call Functionality.set_GLB_rngToCopy(Row)
        If (Functionality.checkIntegrity) Then
            SendData (Row)
            Dim buttonName As String
            buttonName = "Line" & Row
            buttonName.Visible = False
        End If
    Next Row
End Sub

Best regards,
lolo
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You have defined buttonName As a string.

Add this to your code

Code:
Private Sub SubmitAll_Click()
    Dim Row As Integer
Dim wb As workbook, ws As worksheet
Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
    For Row = 15 To 36
        Call Functionality.set_GLB_rngToCopy(Row)
        If (Functionality.checkIntegrity) Then
            SendData (Row)
            Dim buttonName As String
            buttonName = "Line" & Row
            ws.Shapes(buttonName).Visible = msoFalse
        End If
    Next Row
End Sub
 
Upvote 0
Hi Comfy,
Thank you !!

Best regards,
lolo^^
You have defined buttonName As a string.

Add this to your code

Code:
Private Sub SubmitAll_Click()
    Dim Row As Integer
Dim wb As workbook, ws As worksheet
Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
    For Row = 15 To 36
        Call Functionality.set_GLB_rngToCopy(Row)
        If (Functionality.checkIntegrity) Then
            SendData (Row)
            Dim buttonName As String
            buttonName = "Line" & Row
            ws.Shapes(buttonName).Visible = msoFalse
        End If
    Next Row
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

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