View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter atherton Peter atherton is offline
external usenet poster
 
Posts: 9
Default Macro Button To Modify A Cell's Contents?

Virtanis

Here is one way to reduce the selected cells

Sub ReduceByOne()
' reduces values of formulas by 1
' and replaces formula by value
Dim c
For Each c In Selection
c.Value = c - 1
Next c
End Sub

But this converts any formulas you have to a value so you
lose the formula and the link to the other sheet.

To get over this you will have to import the information
by another Macro. And the following gives you an idea.

Sub getValues()
Dim rng As Range
Set rng = Range("B2:C6")
rng = Sheets("Sheet2").Range("B2:C6").Value
End Sub

You can modify these macros and get the button from View,
Toolbars, Forms and choose a Command button then draw it
on your sheet. Right-click to assign macro and then it is
operational.

Remember to format the command button (right-click,
format) and make sure that the button does not print.

Regards
Peter
-----Original Message-----
I'm just starting to look into VBA to help me do things

with my excel
project, but for the most part, I'm a beginner and

totally stumped.

Here is my problem.

On Sheet2 I have a whole range of figures and numbers

displayed which
are pulled from a variety of other pages (say =Sheet1!E2

as an
example). This is an overview page mostly.

What I really need is to make a macro button next to a

display field on
sheet2 that, when pushed, will modify the the actual

contents of the
Sheet1!E2 cell by -1. Each push of that button will

minus 1 from that
cell indefinitely.