Too many macros

B

Barney

In this spreadsheet for my golfing group, I have 45 macros and 45 buttons to
run them. One macro & button per golfer. Is there a way to do the same thing
with one macro and one button where I would merely place the cursor in the
proper name cell and then click the button?

E F G H I
Name Temp Points Rounded New
Quota Scored Diff 1/2 Quota
Bob 24 31 3 27
Fred 21 23 1 22
Hank 22 18 -2 20


A typical macro...............one of 45....... this one for Bob.....

Sub MoveStuff1()
Range("I7").Select
Selection.Copy
Range("F7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("G7").Select
Selection.ClearContents
End Sub

Thanks in advance,

Barney
 
D

Don Guillett

sub doall()
For i=2 to cells(rows.count,"e").end(xlup).row
cells(i,"f").value=cells(i,"I").value
cells(i,"g").clearcontents
next i
end sub
 
B

Bernard Liengme

Try this:
Sub Golfer()
Set mc = Selection
myName = Selection.Value
myColumn = Mid(mc.Address(columnabsolute:=False), 1, 1)

If Len(myName) = 0 Or myColumn <> "E" Then
MsgBox "Please select a name"
Exit Sub
End If

mycell = mc.Address
myreply = MsgBox("Do you want to fix " & myName, vbYesNo)
If myreply = vbYes Then
mySource = ActiveCell.Offset(ColumnOffset:=4)
ActiveCell.Offset(ColumnOffset:=1).Value = mySource
ActiveCell.Offset(ColumnOffset:=2).Clear
End If

End Sub

best wishes
 
D

Don Guillett

My post does all at once with one mouse click. If you want to click for JUST
one then use a doubleclick event which MUST go in the sheet module for the
sheet where your data is. Then double click on the name

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
if target.column<> 5 then exit sub ' column E
i=target.row
cells(i,"f").value=cells(i,"I").value
cells(i,"g").clearcontents
End Sub
 
B

Barney

Thanks to both Don and Bernard. Both solutions worked great. I ended up
using Bernard's because there was no use for the 'do all' capability of
Don's.

Barney
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top