ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to update contents of cell (https://www.excelbanter.com/excel-programming/347138-macro-update-contents-cell.html)

Louise

Macro to update contents of cell
 
I have created a very basic macro which adds 100 onto the value of the
current cell and have assigned it as an icon on my toolbar.

The macro works perfectly, however, I have to run the macro on individual
cells which, if I have a large worksheet can take quite a while. Is there a
way I can adjust/edit the macro so I can select a range of cells and it will
adjust them all at the same time?

I have extremely limited knowledge of VBA!!!

Thank you very much.

Louise

Gary''s Student

Macro to update contents of cell
 
Try:

Sub Macro1()
Dim r As Range
For Each r In Selection
r.Value = r.Value + 100
Next
End Sub

This is also a template to update, in some way, any cells you have selected.
--
Gary's Student


"Louise" wrote:

I have created a very basic macro which adds 100 onto the value of the
current cell and have assigned it as an icon on my toolbar.

The macro works perfectly, however, I have to run the macro on individual
cells which, if I have a large worksheet can take quite a while. Is there a
way I can adjust/edit the macro so I can select a range of cells and it will
adjust them all at the same time?

I have extremely limited knowledge of VBA!!!

Thank you very much.

Louise


Louise

Macro to update contents of cell
 
that works perfectly, thank you very much.

Louise

"Gary''s Student" wrote:

Try:

Sub Macro1()
Dim r As Range
For Each r In Selection
r.Value = r.Value + 100
Next
End Sub

This is also a template to update, in some way, any cells you have selected.
--
Gary's Student


"Louise" wrote:

I have created a very basic macro which adds 100 onto the value of the
current cell and have assigned it as an icon on my toolbar.

The macro works perfectly, however, I have to run the macro on individual
cells which, if I have a large worksheet can take quite a while. Is there a
way I can adjust/edit the macro so I can select a range of cells and it will
adjust them all at the same time?

I have extremely limited knowledge of VBA!!!

Thank you very much.

Louise


Gary''s Student

Macro to update contents of cell
 
You are very welcome.
--
Gary''s Student


"Louise" wrote:

that works perfectly, thank you very much.

Louise

"Gary''s Student" wrote:

Try:

Sub Macro1()
Dim r As Range
For Each r In Selection
r.Value = r.Value + 100
Next
End Sub

This is also a template to update, in some way, any cells you have selected.
--
Gary's Student


"Louise" wrote:

I have created a very basic macro which adds 100 onto the value of the
current cell and have assigned it as an icon on my toolbar.

The macro works perfectly, however, I have to run the macro on individual
cells which, if I have a large worksheet can take quite a while. Is there a
way I can adjust/edit the macro so I can select a range of cells and it will
adjust them all at the same time?

I have extremely limited knowledge of VBA!!!

Thank you very much.

Louise


Matt

Macro to update contents of cell
 
Not sure about the macro, so if no one else responds this may be an
alternate solution: Does the value of the cell meet a certain condition for
you to add 100? If so, you may want to use two rows, such as A and B. Row A
contains your value and Row B contains a formula --- example [Adds 100 if
the value in the A Cell is greater than 70] Cell A1 = 50, Cell A2= 75, Cell
A3=80. Cell B1= "=if(A170,a1+100,a1) The result in B1 would be 50. You can
copy the cell B1 and paste it into B2 & B3 and it will adjust the formula
accordingly. The following results will be: B2 = 175 and B3 = 180.

You can then use the value in column B for whatever use you need.




"Louise" wrote:

I have created a very basic macro which adds 100 onto the value of the
current cell and have assigned it as an icon on my toolbar.

The macro works perfectly, however, I have to run the macro on individual
cells which, if I have a large worksheet can take quite a while. Is there a
way I can adjust/edit the macro so I can select a range of cells and it will
adjust them all at the same time?

I have extremely limited knowledge of VBA!!!

Thank you very much.

Louise



All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com