Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
These are all buttons from the Forms toolbar that have the same macro associated
with each button. If yes, then maybe something like this will help you get started: Option Explicit Sub Day1() Dim RngToCopy As Range Dim DestCell As Range Dim DestCol As Long Dim myBTN As Button With ActiveSheet Set myBTN = .Buttons(Application.Caller) Set RngToCopy = .Range("V7:V28") DestCol = myBTN.TopLeftCell.Column Set DestCell = .Cells(7, DestCol) RngToCopy.Copy _ Destination:=DestCell End With End Sub mattylance wrote: My macro currently looks like this: Sub Day1() ' ' Day1 Macro ' Macro recorded 6/20/2006 by Matt Lance ' ' Range("V7:V28").Select Selection.Copy ActiveWindow.SmallScroll ToRight:=-7 Range("D7").Select ActiveSheet.Paste End Sub What I want to do is have it so that instead of selecting D7 to paste, I want it to select the same column that the command button is in and then the 7th row. This way I can have one macro used across several buttons instead of having a macro for every column I use. Does anybody have any suggestions?? -- mattylance ------------------------------------------------------------------------ mattylance's Profile: http://www.excelforum.com/member.php...o&userid=35070 View this thread: http://www.excelforum.com/showthread...hreadid=553652 -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Run a macro using a command button | Excel Discussion (Misc queries) | |||
Command Button Macro | Excel Programming | |||
How do I hide a command button based on a condition? | Excel Programming | |||
Changing Command Button Based on Data Entry | Excel Programming | |||
Macro/Command Button | Excel Programming |