Error on Macro that paste special multiples a union range by a cell

superskid

Board Regular
Joined
Aug 25, 2006
Messages
160
I am trying to create a macro that takes the value in cell X3 and paste special multiplies it to a lot of cells. I am getting error 424 object required.

Code:
Sub IncreaseSalesBy()'
' IncreaseSalesBy Macro
' Increase sales by percent in X3 on Budget Workbooks
'


'
    Dim Rng1, Rng2, Rng3 As Range
    
    Set Rng1 = Range("B172:H172,B179:H179,B186:H186,B193:H193,B200:H200,B217:H217,B224:H224,B231:H231,B238:H238,B245:H245,B252:H252,N217:T217,N224:T224,N231:T231,N238:T238,N245:T245,N252:T252,B269:H269,B276:H276,B283:H283,B290:H290,B297:H297,B304:H304,B321:H321,B328:H328")
    Set Rng1 = Range("N342:T342,N349:T349,N356:T356,B373:H373,B380:H380,B387:H387,B394:H394,B401:H401,B408:H408,B9,B9:H9,B16:H16,B23:H23,B30:H30,B37:H37,B44:H44,N9:T9,N16:T16,N23:T23,N30:T30,N37:T37,N44:T44,B61:H61,B68:H68,B75:H75,B82:H82,B89:H89,B96:H96,B113:H113,B120:H120")
    Set Rng1 = Range("B141:H141,B148:H148,N113:T113,N120:T120,N127:T127,N134:T134,N141:T141,N148:T148,B165:H165,B127:H127,B134:H134,B335:H335,B342:H342,B349:H349,B356:H356,N321:T321,N328:T328,N335:T335")
    
     
    Range("X3").Select
    Selection.Copy
    Union(Rng1, Rng2, Rng3).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlMultiply, _
        SkipBlanks:=False, Transpose:=False
    Range("V387").Select
End Sub

Bonus, I would also like to have that same union range of cells rounded to the nearest whole number.

Thanks,
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You've set Rng1 3 times.
Try this :
Code:
Sub IncreaseSalesBy()
Dim Rng1 As Range, Rng2 As Range, Rng3 As Range, Rng4 As Range, cel As Range


Set Rng1 = Range("B172:H172,B179:H179,B186:H186,B193:H193,B200:H200,B217:H217,B224:H224,B231:H231,B238:H238,B245:H245,B252:H252,N217:T217,N224:T224,N231:T231,N238:T238,N245:T245,N252:T252,B269:H269,B276:H276,B283:H283,B290:H290,B297:H297,B304:H304,B321:H321,B328:H328")
Set Rng2 = Range("N342:T342,N349:T349,N356:T356,B373:H373,B380:H380,B387:H387,B394:H394,B401:H401,B408:H408,B9,B9:H9,B16:H16,B23:H23,B30:H30,B37:H37,B44:H44,N9:T9,N16:T16,N23:T23,N30:T30,N37:T37,N44:T44,B61:H61,B68:H68,B75:H75,B82:H82,B89:H89,B96:H96,B113:H113,B120:H120")
Set Rng3 = Range("B141:H141,B148:H148,N113:T113,N120:T120,N127:T127,N134:T134,N141:T141,N148:T148,B165:H165,B127:H127,B134:H134,B335:H335,B342:H342,B349:H349,B356:H356,N321:T321,N328:T328,N335:T335")
Set Rng4 = Union(Rng1, Rng2, Rng3)
 
Range("X3").Copy
Rng4.PasteSpecial Paste:=xlPasteValues, Operation:=xlMultiply, _
    SkipBlanks:=False, Transpose:=False
For Each cel In Rng4
    cel = Round(cel, 0)
Next
Range("V387").Select
End Sub
 
Upvote 0
No idea how I didn't see that, thanks. The paste special multiply works but the rounding doesn't. still get cells ending in .5

Edit: Got it to work by changing code to cell.value
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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