I took a formula I use and tried to create a macro with it. For some reason it does not work with the macro, but works fine if the formula is applied to the cells directly. Also, if I goto a cell and then hit the paste function button, the macro gets applied. Is this an excel flaw or more likely poor coding of the macro.. Please help.
Here is the macro I created:
Sub Create_unmatched_Credits_r
eport_from
_detailed_
AR_Report(
)
'
'
Range("A1").Select
Selection.EntireColumn.Ins
ert
Range("A1").Select
ActiveCell.FormulaR1C1 = "Lookup Column"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
Range("A2").Select
ActiveCell.FormulaR1C1 = "=+RC[1]&RC[6]&RC[13]"
Selection.Copy
ActiveCell.SpecialCells(xl
LastCell).
Select
Selection.End(xlToLeft).Se
lect
Selection.End(xlToLeft).Se
lect
Selection.End(xlToLeft).Se
lect
Selection.End(xlToLeft).Se
lect
Range(Selection, Selection.End(xlUp)).Selec
t
ActiveSheet.Paste
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
ActiveCell.SpecialCells(xl
LastCell).
Select
Selection.End(xlToLeft).Se
lect
Range("P28").Select
Selection.End(xlDown).Sele
ct
Selection.End(xlUp).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Borders(xlDiagon
alDown).Li
neStyle = xlNone
Selection.Borders(xlDiagon
alUp).Line
Style = xlNone
With Selection.Borders(xlEdgeLe
ft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 48
End With
Selection.Borders(xlEdgeTo
p).LineSty
le = xlNone
Selection.Borders(xlEdgeBo
ttom).Line
Style = xlNone
With Selection.Borders(xlEdgeRi
ght)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 48
End With
Selection.Borders(xlInside
Vertical).
LineStyle = xlNone
Selection.Borders(xlInside
Horizontal
).LineStyl
e = xlNone
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.NumberFormat = "General"
ActiveCell.FormulaR1C1 = "Should be examined?"
With ActiveCell.Characters(Star
t:=1, Length:=19).Font
.Name = "Courier New"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("P1").Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
Range("P2").Select
ActiveCell.FormulaR1C1 = "=IF(ISERROR(VLOOKUP(rc[-1
4]&""INV""
&(rc[-2]*-
1),A:O,1,F
ALSE)),""N
o"",""Yes"
")"
Range("P2").Select
End Sub