SOLVED

# How To Multiply A Range Of Cells By Same Number In Excel

Highlighted
Occasional Contributor

# How To Multiply A Range Of Cells By Same Number In Excel

Hello,

i Recorded the Macro below:

Sub Conversion()
'
' Conversion Macro
'

'
Range("Y1").Select
Selection.Copy
Range("B11:AE11,B13:AE13,B15:AE15,B17:AE17,B19:AE19,B21:AE21,B23:AE23,B25:AE25,B25:AE25,B27:AE27,B29:AE29,B31:AE31,B33:AE33,B35:AE35,B37:AE37,B39:AE39,B41:AE41,B43:AE43,B45:AE45,B47:AE47,B49:AE49,B51:AE51,B53:AE53,B55:AE55,B57:AE57,B59:AE59,B61:AE61,B63:AE63").Select
' Range("B11:AE11,B13:AE13,B15:AE15,B17:AE17,B19:AE19,B21:AE21,B23:AE23,B25:AE25,B25:AE25,B27:AE27,B29:AE29,B31:AE31,B33:AE33,B35:AE35,B37:AE37,B39:AE39,B41:AE41,B43:AE43,B45:AE45,B47:AE47,B49:AE49,B51:AE51,B53:AE53,B55:AE55,B57:AE57,B59:AE59,B61:AE61,B63:AE63,B65:AE65,B67:AE67,B69:AE69,B71:AE71,B73:AE73,B75:AE75,B77:AE77,B79:AE79,B81:AE81,B83:AE83,B85:AE85,B87:AE87,B89:AE89,B91:AE91,B93:AE93,B95:AE95,B97:AE97,B99:AE99,B101:AE101,B103:AE103,B105:AE105,B107:AE107,B109:AE109,B111:AE111").Select

Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "0"

Range("Y1").Select
Selection.Copy
Range("B65:AE65,B67:AE67,B69:AE69,B71:AE71,B73:AE73,B75:AE75,B77:AE77,B79:AE79,B81:AE81,B83:AE83,B85:AE85,B87:AE87,B89:AE89,B91:AE91,B93:AE93,B95:AE95,B97:AE97,B99:AE99,B101:AE101,B103:AE103,B105:AE105,B107:AE107,B109:AE109,B111:AE111").Select

Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "0"

End Sub

I am multiplying the value in Y1 (single value) with the range listed above(Just the black values in

18-20 LRFD) sheet. When i run the macro, it changes the format in the range. How can i fix it so it won't change the format?

Thanks,

Sam

4 Replies
Highlighted

# Re: How To Multiply A Range Of Cells By Same Number In Excel

Hi Sam,

Try to remove the lines that say:

Selection.NumberFormat = "0"

There are two lines of them in the macro.

@SamFares

Hope that helps

Highlighted

# Re: How To Multiply A Range Of Cells By Same Number In Excel

Thank you Haytham!

This line is to truncate the numbers. My issue is i don't want to change the color  of the cell.

In the top picture below is after multiplication  and removing the line you just told me about. The second picture is what it originally looked like. i Just want to multiply the numbers only without modifying the color of the cell.

Highlighted
Solution

# Re: How To Multiply A Range Of Cells By Same Number In Excel

@SamFares

If so, replace this argument:

`Paste:=xlPasteAll`

With this:

`Paste:=xlValue`

There is two of this in the code.

I hope that helps

Highlighted

# Re: How To Multiply A Range Of Cells By Same Number In Excel

Yes this is the solution.Thank you Haytham!