Multiply selection of cells by 100, whilst keeping formulas and formats, using VBA

jaykay1

New Member
Joined
Nov 4, 2014
Messages
7
Hi,

I tried to post this before and everyone was very helpful but don't think i was clear enough in my explanation, so thought it easier to start again.

I constantly have to change the factor of a large series of random cells by 100.

To do this, I usually

  • enter "100" in a random cell,
  • click copy,
  • highlight all the cells I need to change,
  • paste special - formulas - multiply.
  • But, when doing this as frequently as I do, it takes a while!

Does anyone know how I can do this in <acronym title="visual basic for applications">VBA</acronym>, so that I can just highlight the cells, run the macro and it will automatically paste special, formulas, multiply by "100" for every cell?

A few added complications -

  • I don't want to change any of the cells in the workbook and do not want to have to type in 100 into any cell, I want this to be contained in the VBA.
  • Also, some of the cells I highlight will contain formulas which I would like to remain intact, just with "x100" at the end. i.e. =sum(c1,d1) will become =sum(c1,d1)x100
  • Finally the cells I highlight are usually scattered all over the place and aren't just one continuous region/array.

Any help would be greatly appreciated!
Jay
 

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.
Give this macro a try...
Code:
Sub MultiplySelectionBy100()
  Dim Cell As Range
  For Each Cell In Selection
    If Len(Cell.Value) > 0 And Application.IsNumber(Cell.Value) Then
      If Cell.HasFormula Then
        Cell.Formula = Replace(Cell.Formula, "=", "=100*(") & ")"
      Else
        Cell.Value = 100 * Cell.Value
      End If
    End If
  Next
End Sub
 
Upvote 0
That's great but unfortunately I think that only works for those where I have formulas, sometimes I have constants... any ideas?
 
Upvote 0

Forum statistics

Threads
1,224,836
Messages
6,181,252
Members
453,028
Latest member
letswriteafairytale

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