Macro to Divide certain numbers on a worksheet by 640

seanmodj

New Member
Joined
Oct 8, 2015
Messages
3
I need a macro code to divide select numbers on a worksheet by 640 and then go back and multiply them by 640. I need it to be with a button somehow that gives me the option to click it to do one and click the other option (or unclick) the button to multiply the numbers (which will be referenced in the code) to 640, reverting it back to what it originally was. Please guys, this would be absolutely phenomenal if anyone could at least help steer me in the right direction!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I need a macro code to divide select numbers on a worksheet by 640 and then go back and multiply them by 640.
What so you mean by "select numbers"? Do you mean the values in cells that you have selected or so you mean certain types of number? If the former, will they still be selected when you execute the macro to restore them? If the latter, what quality makes them "select numbers"?
 
Upvote 0
Thank you for the response Mr. Rothstein! I am referring to the values in cells that I have selected, they will still be selected when I execute the macro. These are cells that I need to continuously be able to divide by 640 and go back and revert them to original by multiplying by 640. Thank you so much my friend!!
 
Upvote 0
Thank you for the response Mr. Rothstein! I am referring to the values in cells that I have selected, they will still be selected when I execute the macro. These are cells that I need to continuously be able to divide by 640 and go back and revert them to original by multiplying by 640. Thank you so much my friend!!
You did not answer my second question... will these cells still be selected when you revert them back to their original values?
 
Upvote 0
Yes they will.
Give these macros a try...
Code:
Sub DivideBy640()
  Dim Cell As Range
  For Each Cell In Selection
    Cell.Value = Cell.Value / 640
  Next
End Sub

Sub MultiplyBy640()
  Dim Cell As Range
  For Each Cell In Selection
    Cell.Value = Cell.Value * 640
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,386
Messages
6,124,628
Members
449,176
Latest member
Dazjlbb

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