Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy into Row holding Button
On my worksheet I have a button that inserts a copied row from anothe
sheet when pressed. The code is as follows: Sub NEWRMO() ' ' NEWRMO Macro ' Macro recorded 02/09/2004 by charles ' ' Sheets("Template").Select Rows("11:11").EntireRow.Copy Sheets("Risk Register").Select ActiveCell.Offset(0, 0).Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown End Sub At present the row is pasted wherever the active cell is, however would like the macro to insert the row on the same line as the butto was when pressed. Presumably I need to get the macro to select the row relative to th button that operates it? Any ideas? One other issue might be that the button is itself copied several time and so exists several times on the same sheet. Perhaps a bette explanation is to explain what the sheet does. It is a Risk register t record project risks. There exists a macro to add a new risk (which i two rows of data, the second being a row with a mitigation option), a well as the two rows of data it also copies the button as describe above. This button activates the macro printed above and insert another mitigation option. Dont know if this paragraph helps if no please disregard -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy into Row holding Button
Hi nejlangton; Sub NEWRMO2() ' ' NEWRMO Macro ' Macro recorded 02/09/2004 by charles ' ' Sheets("Template").Select MyRowToUse = 11 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 Thanks, Greg -----Original Message----- On my worksheet I have a button that inserts a copied row from another sheet when pressed. The code is as follows: Sub NEWRMO() ' ' NEWRMO Macro ' Macro recorded 02/09/2004 by charles ' ' Sheets("Template").Select Rows("11:11").EntireRow.Copy Sheets("Risk Register").Select ActiveCell.Offset(0, 0).Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown End Sub At present the row is pasted wherever the active cell is, however I would like the macro to insert the row on the same line as the button was when pressed. Presumably I need to get the macro to select the row relative to the button that operates it? Any ideas? One other issue might be that the button is itself copied several times and so exists several times on the same sheet. Perhaps a better explanation is to explain what the sheet does. It is a Risk register to record project risks. There exists a macro to add a new risk (which is two rows of data, the second being a row with a mitigation option), as well as the two rows of data it also copies the button as described above. This button activates the macro printed above and inserts another mitigation option. Dont know if this paragraph helps if not please disregard! --- Message posted from http://www.ExcelForum.com/ . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy into Row holding Button
Thanks, but that means that the row is always inserted on row 11. I wan
it to insert on the same row as the button was when pressed, regardles of where that button was positioned because it will move down as row are inserted. i.e. perhaps something like myrowtouse = the same row the button i when pressed. Is there anyway of doing this? Nejl GJones wrote: [b]Hi nejlangton; Sub NEWRMO2() ' ' NEWRMO Macro ' Macro recorded 02/09/2004 by charles ' ' Sheets("Template").Select MyRowToUse = 11 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 Thanks, Gre -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Indirect formulas in cells not holding cell format after copy | Excel Worksheet Functions | |||
holding the result constant | Excel Worksheet Functions | |||
holding a value after first calcuation | Excel Worksheet Functions | |||
Delete a custom button by holding down the ALT key and dragging the button off the toolbar | Excel Programming | |||
#Holding values in different format# | Excel Programming |