macro combine help

danushka

Well-known Member
Joined
Sep 6, 2009
Messages
693
Hi, i have recoded some macros & modified some old macros. so i want combine bellow all the macros & need to make one short macro(removing unwanted codes). code should combine as per below , pls help me to do this..

UnMerge rows.
Code:
Range("A1:M1").Select
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = True
    End With
    Selection.UnMerge

inset new 2 columns
Code:
Columns("L:M").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

adding two text
Code:
Range("L2").Select
    ActiveCell.FormulaR1C1 = "Pend Ord"
   
    Range("M2").Select
    ActiveCell.FormulaR1C1 = "Free Stk"

add value of two formula result
Code:
With Range("L3:L" & Range("D" & Rows.Count).End(xlUp).Row)
        .FormulaR1C1 = "=SUMIFS(R2C11:R[-1]C[-1],R2C4:R[-1]C[-8],RC[-8],R2C5:R[-1]C[-7],RC[-7],R2C6:R[-1]C[-6],RC[-6],R2C7:R[-1]C[-5],RC[-5],R2C8:R[-1]C[-4],RC[-4],R2C9:R[-1]C[-3],RC[-3])"
        .Value = .Value

With Range("M3:M" & Range("D" & Rows.Count).End(xlUp).Row)
        .FormulaR1C1 = "=RC[1]-RC[-1]"
        .Value = .Value
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
What's keeping you from just putting all of the code snippets together into one routine?

Other than getting rid of the Select statements it's pretty straightforward, although for the first part, why merge cells then unmerge them?
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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