ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to add value of (1) to a selected cell or cells? (https://www.excelbanter.com/excel-discussion-misc-queries/445785-macro-add-value-1-selected-cell-cells.html)

Coaxis

Macro to add value of (1) to a selected cell or cells?
 
I'm comfortable with excel and formulas but never used any of the developer features.

Can anyone tell me how I could:
click a button I have created on the sheet that will change the value of highlighted cells to the value (1) and fill the cells with a color?

In my head this is how it would work:
1) highlight a group of cells
2) Click the button
All highlighted cells would now contain the value 1 and be filled yellow.

I can create the button and assign a macro to it. I just have no idea how to write the macro, or if its even possible.

I'm open to other ideas if I am going about this all wrong.

Gord Dibben[_2_]

Add value of (1) to a selected cell or cells
 
Sub One_And_Color()
Dim rng As Range
Set rng = Selection
With rng
.Value = 1
.Interior.Color = vbYellow
End With
End Sub


Gord


On Mon, 16 Apr 2012 21:44:17 +0000, Coaxis
wrote:


I'm comfortable with excel and formulas but never used any of the
developer features.

Can anyone tell me how I could:
click a button I have created on the sheet that will change the value of
highlighted cells to the value (1) and fill the cells with a color?

In my head this is how it would work:
1) highlight a group of cells
2) Click the button
All highlighted cells would now contain the value 1 and be filled
yellow.

I can create the button and assign a macro to it. I just have no idea
how to write the macro, or if its even possible.

I'm open to other ideas if I am going about this all wrong.


Coaxis

Worked perfectly! just as I described.

Thanks for your help Gord!

Gord Dibben[_2_]

Macro to add value of (1) to a selected cell or cells?
 
Good to hear.

Thanks for the feedback.

On Tue, 17 Apr 2012 18:28:14 +0000, Coaxis
wrote:


Worked perfectly! just as I described.

Thanks for your help Gord!



All times are GMT +1. The time now is 02:57 AM.

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