Macro to add 0.1 to values in cells within a user selected range

Luy135

New Member
Joined
Aug 23, 2017
Messages
2
Hello all, i am fairly new to Excel in general and am still trying to learn the basics. When it comes to Macros i know just about ZERO. Anyway i was hoping to find some help here.

I have a 15x30 cell table each cell has a specific predetermined value. I would like to set up a Button with a Macro that would allow me to use the mouse to highlight any range of cells withing the table and click the button to add 0.1 to the existing values in those selected cells. Any ideas?

I'm sure this is probably something fairly simple but i am a complete novice so please forgive me.

Thank you,
Lou
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Code:
Sub addto()
Dim d As Range
Set d = Cells(Rows.Count, Columns.Count)
d = 0.1
d.Copy
Selection.PasteSpecial , xlPasteSpecialOperationAdd
d.Delete
End Sub
 
Last edited:
Upvote 0
Welcome to the Board!

Here is the VBA code that you would need that will run against all cells in your selection.
Code:
Sub AddValue()

    Dim cell As Range
    
    Application.ScreenUpdating = False
    
'   Loop through all cells in the selection
    For Each cell In Selection
'       If the existing value is numeric, add 0.01 to it
        If IsNumeric(cell) Then
            cell = cell + 0.01
        End If
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub
And then you can just assign it to a button. The following links show you various ways of doing that: Assign a macro to a Form or a Control button - Excel
 
Upvote 0
EXCELLENT!!!! Those work perfectly! Thank you very much. I can't believe i had been driving myself crazy for the last 2 days trying to figure this out on my own haha
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top