Button on every row excel - paste values into another sheet

Big_OT

New Member
Joined
Jan 17, 2018
Messages
7
Hello,

I have 2 sheets in my workbook, one is a table of data and the other manipulates one row of the data from the table based on the unique ID in column C of the table which I type in/select from list into the 2nd sheet.
Is it possible to have a button on every row on the table in column P which when pressed pastes the unique ID of that row (from column C of that row) into the entry box in the 2nd sheet ($C$19) ?

TIA,
OT
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Ok so this is the code I use to create the Buttons:

Code:
Sub CreateButtons()

    Dim i As Long
    Dim shp As Object
    Dim dblLeft As Double
    Dim dblTop As Double
    Dim dblWidth As Double
    Dim dblHeight As Double
        
    With Sheets("Sheet1")
        dblLeft = .Columns("M:M").Left
        dblWidth = .Columns("M:M").Width
        For i = 3 To 20
            dblHeight = .Rows(i).Height
            dblTop = .Rows(i).Top
            Set shp = .Buttons.Add(dblLeft, dblTop, dblWidth, dblHeight)
            shp.OnAction = "IdentifySelected"
            shp.Characters.Text = "CLICK HERE"
        Next i
    End With
   
End Sub


Sub IdentifySelected()
    Dim strButtonName
    Dim lngRow As Long
    
    strButtonName = ActiveSheet.Shapes(Application.Caller).Name
    RowNumber = ActiveSheet.Shapes(strButtonName).TopLeftCell.Row
    
    MsgBox "Button is on row " & RowNumber
End Sub

and this is the code I use to copy and paste

Code:
Sub RunAllMacros()
Procedure1
Procedure2
End Sub


Sub Procedure1()
Worksheets("Sheet2").Range("C19").Value = Worksheets("Sheet1").Range("B9").Value
End Sub
 
Sub Procedure2()
    Sheets("INV").Select
End Sub

It is a hybrid between these code I think I need to use, I want the macro to automatically be assigned to each button when created and it is the "B9" in the code that I want to be B&Whatever row the button is on.

TIA,
OT
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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