I have two sets of code, The first one, copies and inserts the copied range on to a different sheet and the Second, copies and pastes the range on to a different sheet. There is one line of code that has to be different for me. I put the lines in question in bold. Why is this? Does it have to do something with VBA objects? I am fairly new and was wondering why such a small change makes programming seem more frustrating than it often appears. Is there any easier way write either of these codes?
Sub CopyandInsert()
'This code copies and inserts via shift cells down.
ThisWorkbook.Worksheets("Sheet1").Select
ActiveSheet.Range("A2:D5").Select
Selection.Copy
ThisWorkbook.Worksheets("Sheet2").Select
ActiveSheet.Range("A12:D15").Select
Selection.Insert Shift:=xlDown
Columns("D:D").NumberFormat = "$0.00"
End Sub
Sub CandP()
'This code copies and pastes
ThisWorkbook.Worksheets("Sheet1").Select
ActiveSheet.Range("A2:D4").Select
Selection.Copy
ThisWorkbook.Worksheets("Sheet2").Select
ActiveSheet.Range("A4:D6").Select
ActiveSheet.Paste
Columns("D:D").NumberFormat = "$0.00"
End Sub
Sub CopyandInsert()
'This code copies and inserts via shift cells down.
ThisWorkbook.Worksheets("Sheet1").Select
ActiveSheet.Range("A2:D5").Select
Selection.Copy
ThisWorkbook.Worksheets("Sheet2").Select
ActiveSheet.Range("A12:D15").Select
Selection.Insert Shift:=xlDown
Columns("D:D").NumberFormat = "$0.00"
End Sub
Sub CandP()
'This code copies and pastes
ThisWorkbook.Worksheets("Sheet1").Select
ActiveSheet.Range("A2:D4").Select
Selection.Copy
ThisWorkbook.Worksheets("Sheet2").Select
ActiveSheet.Range("A4:D6").Select
ActiveSheet.Paste
Columns("D:D").NumberFormat = "$0.00"
End Sub