Sean15
Well-known Member
- Joined
- Jun 25, 2005
- Messages
- 719
- Office Version
- 2010
- Platform
- Windows
VBA Code:
Sub Macro2()
'
' Macro2 Macro
'
'
Range("P1").Select
ActiveCell.FormulaR1C1 = "Cost Center"
Range("Q1").Select
ActiveCell.FormulaR1C1 = "Division"
Range("R2").Select
ActiveCell.FormulaR1C1 = "1"
Range("R2").Select
Selection.Copy
Range("C2:C8").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("P2").Select
ActiveCell.FormulaR1C1 = "=RIGHT(RC[-13],3)*1"
Range("P2").Select
Selection.AutoFill Destination:=Range("P2:P8"), Type:=xlFillDefault
Range("P2:P8").Select
Range("Q2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(IFERROR(VLOOKUP(RC[-14],'lookup values'!R2C1:R27C2,2,0),VLOOKUP(RC[-1],'lookup values'!R2C1:R27C2,2,0)),"""")"
Range("Q2").Select
Selection.AutoFill Destination:=Range("Q2:Q8"), Type:=xlFillDefault
Range("Q2:Q8").Select
Range("M9").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-7]C:R[-1]C)"
Range("M10").Select
End Sub
Column C – I’m converting numbers formatted as text to numbers so I’d like “PasteSpecial *1 to extend to the last row of data, and not a range.
Column P – I’d like to extend formula to the last row of data, and not a range.
Column R – I had to add 1 in row R2 to help execute the PastSpecial*1 in column C. Is there a more efficient way to execute the PastSpecial*1 without adding 1 in R2?
Column Q - I’d like to extend formula to the last row of data, and not a range.
S2 – I added VLookup formula in S2 to help insert formula in column Q. Is there a better way to do this?
M9 - could we add subtotal to the row following the last row of data in column M
Thank you for your help.