Excel question

  • Thread starter Thread starter Swinder
  • Start date Start date
S

Swinder

I have a very basic spreadsheet with data in it. What I want to be
able to do is add a button that a user can click which will execute a
basic command of simply adding a fixed amount (like +7) to a specific
set of the data and another amount to another column of data. I
imagine this is pretty simple to do, but I can not quite figure it
out.

~Thanks.
 
sub addnum()
for each c in selection
c.value = c.value+7
next c
end sub

game time
 
sub addnum()
for each c in selection
c.value = c.value+7
next c
end sub

game time

Appreciate the reply, I am afraid my inexperience here is getting the
best of me though. Not really sure what to do with the info you gave
me.
 
sub addnum()
for each c in selection
c.value = c.value+7
next c
end sub

game time

Thanks for the fast reply. I understand how to put that in VB and I
see where I can select cells and then run it and have it make the
change. Is there a way though I can make like a button or something on
the worksheet itself that I can simply click on to have it run this
without having to select the cells and then go into the VB editor
every time? That part I can't seem to get.
 
Add a button to the sheet and assign this code to it. Adapt MyRange to suit
your sheet needs.

Sub addnum()
Dim MyRange As Range
Dim c As Range
Set MyRange = Range("F1:F10")
' Or for multiple ranges
'Set MyRange = Range("F1:F10,H1:J5")
For Each c In MyRange
c.Value = c.Value + 7
Next c
End Sub

HTH
Regards,
Howard
 
Get a button or shape or any shape from anywhere and right click on it to
assign to the macro.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
sub addnum()
for each c in selection
c.value = c.value+7
next c
end sub

game time

Thanks for the fast reply. I understand how to put that in VB and I
see where I can select cells and then run it and have it make the
change. Is there a way though I can make like a button or something on
the worksheet itself that I can simply click on to have it run this
without having to select the cells and then go into the VB editor
every time? That part I can't seem to get.
 
Get a button or shape or any shape from anywhere and right click on it to
assign to the macro.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software





Thanks for the fast reply. I understand how to put that in VB and I
see where I can select cells and then run it and have it make the
change. Is there a way though I can make like a button or something on
the worksheet itself that I can simply click on to have it run this
without having to select the cells and then go into the VB editor
every time? That part I can't seem to get.

Ok so I was able to create a button and I see how to edit the macro in
it to have it do what I want. Unfortunately now when I try to actually
click on it to run it it tells me: "Can not run the macro. The macro
may not be available in this workbook or all macros may be disabled."
I have it set to enable all macros.
 
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Get a button or shape or any shape from anywhere and right click on it to
assign to the macro.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software





Thanks for the fast reply. I understand how to put that in VB and I
see where I can select cells and then run it and have it make the
change. Is there a way though I can make like a button or something on
the worksheet itself that I can simply click on to have it run this
without having to select the cells and then go into the VB editor
every time? That part I can't seem to get.

Ok so I was able to create a button and I see how to edit the macro in
it to have it do what I want. Unfortunately now when I try to actually
click on it to run it it tells me: "Can not run the macro. The macro
may not be available in this workbook or all macros may be disabled."
I have it set to enable all macros.
 
      If desired, send your file to my address below. I will only look if:
      1. You send a copy of this message on an inserted sheet
      2. You give me the newsgroup and the subject line
      3. You send a clear explanation of what you want
      4. You send before/after examples and expected results.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software






Ok so I was able to create a button and I see how to edit the macro in
it to have it do what I want. Unfortunately now when I try to actually
click on it to run it it tells me: "Can not run the macro. The macro
may not be available in this workbook or all macros may be disabled."
I have it set to enable all macros.

I appreciate the offer, I just sent you an e-mail.
 
When replying to me TOP post
Did NOT get your file. Did you send to my address below

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
� � � If desired, send your file to my address below. I will only look if:
� � � 1. You send a copy of this message on an inserted sheet
� � � 2. You give me the newsgroup and the subject line
� � � 3. You send a clear explanation of what you want
� � � 4. You send before/after examples and expected results.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software






Ok so I was able to create a button and I see how to edit the macro in
it to have it do what I want. Unfortunately now when I try to actually
click on it to run it it tells me: "Can not run the macro. The macro
may not be available in this workbook or all macros may be disabled."
I have it set to enable all macros.

I appreciate the offer, I just sent you an e-mail.
 
Back
Top