Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to run in same row as selected button

cheers Tom, thats a great help

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Option Button - multiple selected alanap Excel Worksheet Functions 1 April 17th 06 11:04 PM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
Activate button when row selected. Johnnyb Excel Programming 3 August 17th 04 01:51 PM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM
Button to format selected text as subscript John[_79_] Excel Programming 2 April 4th 04 01:37 AM


All times are GMT +1. The time now is 04:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"