Liberteric
New Member
- Joined
- Sep 29, 2014
- Messages
- 28
I've been running the macro below manually. I would like a macro to test column A which contains an If statement IF(B1=E1,1,0) on each row until row A is empty.
I tried a suggestion from here before and if the value was 0, it called up this macro but the macro saw the value of 1 as a 0. If you can help, that would be great.
Sub AddLine()
' Addline Macro
'
'
Application.ScreenUpdating = False
Application.CutCopyMode = False
Range(Selection, Selection.End(xlToRight).Offset(, 13)).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(-1, -4).Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(1, 1).Select
' Start New GL Code list
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("NEWGL").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1).Select
ActiveSheet.Paste
Sheets("TB").Select
Application.CutCopyMode = False
'Fill New Code data
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
ActiveCell.Offset(, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(, 2).Select
ActiveCell.FormulaR1C1 = "0"
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlToRight).Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToLeft)).Select
ActiveCell.Offset(-1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(, -1).Select
Selection.ClearContents
Application.CutCopyMode = False
'Get Record location
ActiveCell.Offset(, 1).Select
ActiveCell.Formula = "=CELL(""address"")"
Application.CutCopyMode = False
ActiveCell.Offset(, -3).Select
Selection.Copy
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(, 3).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Sheets("NEWGL").Select
Range("D1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1).Select
ActiveSheet.Paste
Sheets("TB").Select
'Return to column E
Application.CutCopyMode = False
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(, 4).Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
I tried a suggestion from here before and if the value was 0, it called up this macro but the macro saw the value of 1 as a 0. If you can help, that would be great.
Sub AddLine()
' Addline Macro
'
'
Application.ScreenUpdating = False
Application.CutCopyMode = False
Range(Selection, Selection.End(xlToRight).Offset(, 13)).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(-1, -4).Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(1, 1).Select
' Start New GL Code list
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("NEWGL").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1).Select
ActiveSheet.Paste
Sheets("TB").Select
Application.CutCopyMode = False
'Fill New Code data
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
ActiveCell.Offset(, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(, 2).Select
ActiveCell.FormulaR1C1 = "0"
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlToRight).Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToLeft)).Select
ActiveCell.Offset(-1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(, -1).Select
Selection.ClearContents
Application.CutCopyMode = False
'Get Record location
ActiveCell.Offset(, 1).Select
ActiveCell.Formula = "=CELL(""address"")"
Application.CutCopyMode = False
ActiveCell.Offset(, -3).Select
Selection.Copy
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(, 3).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Sheets("NEWGL").Select
Range("D1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1).Select
ActiveSheet.Paste
Sheets("TB").Select
'Return to column E
Application.CutCopyMode = False
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(, 4).Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub