Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to run in same row as selected button
Hi, below I have posted my code which is designed to insert a copied row in
whichever row a button is when it is clicked. What am I doing wrong? it seems to get as far as the 'Cells(MyRowToUse, 1).Select' line of code. I am a beginer so suspect it may be something simple but help would be appreciated. N Sub NEWRMO() ' ' NEWRMO Macro ' Macro recorded 02/09/2004 by charles ' ' Dim BTN As Button Dim MyRowToUse As Variant MyRowToUse = ActiveSheet.Buttons(Application.Caller).TopLeftCel l.Address '.row, .column MsgBox MyRowToUse Sheets("Template").Select Rows("11:11").EntireRow.Copy Sheets("Risk Register").Select Cells(MyRowToUse, 1).Select ActiveCell.Offset(0, 0).Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to run in same row as selected button
myrowtouse will have a value like B21
Sub NEWRMO() ' ' NEWRMO Macro ' Macro recorded 02/09/2004 by charles ' ' Dim BTN As Button Dim MyRowToUse As Variant MyRowToUse = ActiveSheet.Buttons(Application.Caller).TopLeftCel l.row '.row, .column MsgBox MyRowToUse Sheets("Template").Rows("11:11").EntireRow.Copy Sheets("Risk Register").Cells( _ MyRowToUse, 1).Insert Shift:=xlShiftDown End Sub This shifts you button down. -- Regards, Tom Ogilvy "nejl" wrote in message ... Hi, below I have posted my code which is designed to insert a copied row in whichever row a button is when it is clicked. What am I doing wrong? it seems to get as far as the 'Cells(MyRowToUse, 1).Select' line of code. I am a beginer so suspect it may be something simple but help would be appreciated. N Sub NEWRMO() ' ' NEWRMO Macro ' Macro recorded 02/09/2004 by charles ' ' Dim BTN As Button Dim MyRowToUse As Variant MyRowToUse = ActiveSheet.Buttons(Application.Caller).TopLeftCel l.Address '.row, .column MsgBox MyRowToUse Sheets("Template").Select Rows("11:11").EntireRow.Copy Sheets("Risk Register").Select Cells(MyRowToUse, 1).Select ActiveCell.Offset(0, 0).Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to run in same row as selected button
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Option Button - multiple selected | Excel Worksheet Functions | |||
How do I lock a radio button group if a N/A button is selected | Excel Discussion (Misc queries) | |||
Activate button when row selected. | Excel Programming | |||
Pause macro, add form button to sheet, continue macro when button clicked! | Excel Programming | |||
Button to format selected text as subscript | Excel Programming |