maddavid123
New Member
- Joined
- Mar 20, 2012
- Messages
- 2
I have a Macro Where i am trying to Have the Data In Sheet1 and Sheet2 into sheet3 This is my Macro.
Sub moveitems()
'
' moveitems Macro
' This is To Put the Items in Sheet1 and sheet2 Into Sheet3 With Data.
'
'
Range("B1,C1,D1,E1").Select
Range("Table1[[#Headers],[18th]]").Activate
Sheets("Sheet2").Select
Range("B1,C1,D1,E1").Select
Range("Table13[[#Headers],[22nd]]").Activate
Sheets("Sheet1").Select
Range("Table1[[#Headers],[15th]]").Select
Selection.Copy
Range("B11").Select
ActiveSheet.Paste
Range("Table1[[#Headers],[16th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("Table1[[#Headers],[17th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("D11").Select
ActiveSheet.Paste
Range("E11").Select
Application.CutCopyMode = False
Selection.Copy
Range("Table1[[#Headers],[18th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("E11").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("Table13[[#Headers],[19th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("B11").Select
ActiveSheet.Paste
Range("C2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
Range("Table13[[#Headers],[20th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("Table13[[#Headers],[21st]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("D11").Select
ActiveSheet.Paste
Range("Table13[[#Headers],[22nd]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("E11").Select
ActiveSheet.Paste
Range("A38").Select
Sheets("Sheet1").Select
Range("C11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("B12")
Range("D11").Select
Selection.Cut Destination:=Range("B13")
Range("E11").Select
Selection.Cut Destination:=Range("B14")
Range("B11:B14").Select
Range("B14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("B2").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("C11:E11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("B12:D12")
Range("B12:D12").Select
Selection.Cut Destination:=Range("B13:D13")
Range("B13").Select
Selection.Cut Destination:=Range("B12")
Range("C13:D13").Select
Range("D13").Activate
Selection.Cut Destination:=Range("B13:C13")
Range("C13").Select
Selection.Cut Destination:=Range("B14")
Range("B11:B14").Select
Range("B14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("B6").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("B2:E2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("D11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("C12")
Range("E11").Select
Selection.Cut Destination:=Range("C13")
Range("F11").Select
Selection.Cut Destination:=Range("C14")
Range("C11:C14").Select
Selection.Copy
Sheets("Sheet2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("C6").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B2:E2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("D11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("C12")
Range("E11:F11").Select
Selection.Cut Destination:=Range("C13:D13")
Range("D13").Select
Selection.Cut Destination:=Range("C14")
Range("C15").Select
ActiveCell.FormulaR1C1 = ""
Range("C11:C14").Select
Range("C14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("C2").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("B3:E3").Select
Application.CutCopyMode = False
Selection.Copy
Range("D11").Select
ActiveSheet.Paste
Range("E11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("D12")
Range("F11").Select
Selection.Cut Destination:=Range("D13")
Range("G11").Select
Selection.Cut Destination:=Range("D14")
Range("B4:E4").Select
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Range("E11").Select
ActiveSheet.Paste
Range("F11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("E12")
Range("G11").Select
Selection.Cut Destination:=Range("E13")
Range("H11").Select
Selection.Cut Destination:=Range("E14")
Range("B5:E5").Select
Selection.Copy
Range("F11").Select
ActiveSheet.Paste
Range("G11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("F12")
Range("H11").Select
Selection.Cut Destination:=Range("F13")
Range("I11").Select
Selection.Cut Destination:=Range("F14")
Range("B6:E6").Select
Selection.Copy
Range("G11").Select
ActiveSheet.Paste
Range("H11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("G12")
Range("I11:J11").Select
Selection.Cut Destination:=Range("G13:H13")
Range("H13").Select
Selection.Cut Destination:=Range("G14")
Range("B7:E7").Select
Selection.Copy
Range("H11").Select
ActiveSheet.Paste
Range("I11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("H12")
Range("J11").Select
Selection.Cut Destination:=Range("H13")
Range("K11").Select
Selection.Cut Destination:=Range("H14")
Range("B8:E8").Select
Range("K11").Select
Selection.Cut Destination:=Range("H14")
Range("B8:E8").Select
Selection.Copy
Range("I11").Select
ActiveSheet.Paste
Range("J11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("I12")
Range("K11").Select
Selection.Cut Destination:=Range("I13")
Range("L11").Select
Selection.Cut Destination:=Range("I14")
Range("I14").Select
Sheets("Sheet3").Select
Range("B38").Select
Sheets("Sheet2").Select
Range("D11:D14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("D6").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("E11:E14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("E6:E9").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("F11:F14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("F6").Select
ActiveSheet.Paste
Range("F1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Male or Female?"
Range("B39").Select
Sheets("Sheet2").Select
Range("G11:G14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("G6").Select
ActiveSheet.Paste
Range("F1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Amount of Drivers"
Sheets("Sheet2").Select
Range("H11:H14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("H6").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("I11:I14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("I6").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B3:E3").Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Cut Destination:=Range("D10:G10")
Range("D10:G10").Select
Selection.Cut Destination:=Range("D11:G11")
Range("E11").Select
Selection.Cut Destination:=Range("D12")
Range("F11").Select
Selection.Cut Destination:=Range("D13")
Range("G11").Select
Selection.Cut Destination:=Range("D14")
Range("D11:D14").Select
Range("D14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("D2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B4:E4").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("E11:H11")
Range("F11").Select
Selection.Cut Destination:=Range("E12")
Range("G11").Select
Selection.Cut Destination:=Range("E13")
Range("H11").Select
Selection.Cut Destination:=Range("E14")
Range("E14").Select
ActiveCell.FormulaR1C1 = "3"
Range("E11:E14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("E2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B5:E5").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("F11:I11")
Range("G11").Select
Selection.Cut Destination:=Range("F12")
Range("H11").Select
Selection.Cut Destination:=Range("F13")
Range("I11").Select
Selection.Cut Destination:=Range("F14")
Range("F11:F14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("F2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B6:E8").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("G11:J13")
Range("G12:J13").Select
Selection.Cut Destination:=Range("H12:K13")
Range("H13:K13").Select
Selection.Cut Destination:=Range("I14:L14")
Range("H11").Select
Selection.Cut Destination:=Range("G12")
Range("I11").Select
Selection.Cut Destination:=Range("G13")
Range("J11").Select
Selection.Cut Destination:=Range("G14")
Range("H12").Select
Selection.Cut Destination:=Range("H11")
Range("I12").Select
Selection.Cut Destination:=Range("H12")
Range("J12").Select
Selection.Cut Destination:=Range("I12")
Range("I12").Select
Selection.Cut Destination:=Range("H13")
Range("K12").Select
Selection.Cut Destination:=Range("H14")
Range("I14").Select
Selection.Cut Destination:=Range("I11")
Range("J14").Select
Selection.Cut Destination:=Range("I12")
Range("K14").Select
Selection.Cut Destination:=Range("I13")
Range("L14").Select
Selection.Cut Destination:=Range("I14")
Range("I14").Select
Sheets("Sheet2").Select
Range("A39").Select
Sheets("Sheet1").Select
Range("G11:G14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("G2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("H11:H14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("H2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("I11:I14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("I2").Select
ActiveSheet.Paste
End Sub
And then It Works on the First Worksheet i open, BUT When i go on a Diffrent Worksheet then i cant use it i get the error message "Runtime Error 1004 Method 'range of object'_Global' failed"
Sub moveitems()
'
' moveitems Macro
' This is To Put the Items in Sheet1 and sheet2 Into Sheet3 With Data.
'
'
Range("B1,C1,D1,E1").Select
Range("Table1[[#Headers],[18th]]").Activate
Sheets("Sheet2").Select
Range("B1,C1,D1,E1").Select
Range("Table13[[#Headers],[22nd]]").Activate
Sheets("Sheet1").Select
Range("Table1[[#Headers],[15th]]").Select
Selection.Copy
Range("B11").Select
ActiveSheet.Paste
Range("Table1[[#Headers],[16th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("Table1[[#Headers],[17th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("D11").Select
ActiveSheet.Paste
Range("E11").Select
Application.CutCopyMode = False
Selection.Copy
Range("Table1[[#Headers],[18th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("E11").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("Table13[[#Headers],[19th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("B11").Select
ActiveSheet.Paste
Range("C2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
Range("Table13[[#Headers],[20th]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("Table13[[#Headers],[21st]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("D11").Select
ActiveSheet.Paste
Range("Table13[[#Headers],[22nd]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("E11").Select
ActiveSheet.Paste
Range("A38").Select
Sheets("Sheet1").Select
Range("C11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("B12")
Range("D11").Select
Selection.Cut Destination:=Range("B13")
Range("E11").Select
Selection.Cut Destination:=Range("B14")
Range("B11:B14").Select
Range("B14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("B2").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("C11:E11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("B12:D12")
Range("B12:D12").Select
Selection.Cut Destination:=Range("B13:D13")
Range("B13").Select
Selection.Cut Destination:=Range("B12")
Range("C13:D13").Select
Range("D13").Activate
Selection.Cut Destination:=Range("B13:C13")
Range("C13").Select
Selection.Cut Destination:=Range("B14")
Range("B11:B14").Select
Range("B14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("B6").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("B2:E2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("D11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("C12")
Range("E11").Select
Selection.Cut Destination:=Range("C13")
Range("F11").Select
Selection.Cut Destination:=Range("C14")
Range("C11:C14").Select
Selection.Copy
Sheets("Sheet2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("C6").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B2:E2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C11").Select
ActiveSheet.Paste
Range("D11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("C12")
Range("E11:F11").Select
Selection.Cut Destination:=Range("C13:D13")
Range("D13").Select
Selection.Cut Destination:=Range("C14")
Range("C15").Select
ActiveCell.FormulaR1C1 = ""
Range("C11:C14").Select
Range("C14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("C2").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("B3:E3").Select
Application.CutCopyMode = False
Selection.Copy
Range("D11").Select
ActiveSheet.Paste
Range("E11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("D12")
Range("F11").Select
Selection.Cut Destination:=Range("D13")
Range("G11").Select
Selection.Cut Destination:=Range("D14")
Range("B4:E4").Select
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Range("E11").Select
ActiveSheet.Paste
Range("F11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("E12")
Range("G11").Select
Selection.Cut Destination:=Range("E13")
Range("H11").Select
Selection.Cut Destination:=Range("E14")
Range("B5:E5").Select
Selection.Copy
Range("F11").Select
ActiveSheet.Paste
Range("G11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("F12")
Range("H11").Select
Selection.Cut Destination:=Range("F13")
Range("I11").Select
Selection.Cut Destination:=Range("F14")
Range("B6:E6").Select
Selection.Copy
Range("G11").Select
ActiveSheet.Paste
Range("H11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("G12")
Range("I11:J11").Select
Selection.Cut Destination:=Range("G13:H13")
Range("H13").Select
Selection.Cut Destination:=Range("G14")
Range("B7:E7").Select
Selection.Copy
Range("H11").Select
ActiveSheet.Paste
Range("I11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("H12")
Range("J11").Select
Selection.Cut Destination:=Range("H13")
Range("K11").Select
Selection.Cut Destination:=Range("H14")
Range("B8:E8").Select
Range("K11").Select
Selection.Cut Destination:=Range("H14")
Range("B8:E8").Select
Selection.Copy
Range("I11").Select
ActiveSheet.Paste
Range("J11").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("I12")
Range("K11").Select
Selection.Cut Destination:=Range("I13")
Range("L11").Select
Selection.Cut Destination:=Range("I14")
Range("I14").Select
Sheets("Sheet3").Select
Range("B38").Select
Sheets("Sheet2").Select
Range("D11:D14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("D6").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("E11:E14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("E6:E9").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("F11:F14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("F6").Select
ActiveSheet.Paste
Range("F1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Male or Female?"
Range("B39").Select
Sheets("Sheet2").Select
Range("G11:G14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("G6").Select
ActiveSheet.Paste
Range("F1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Amount of Drivers"
Sheets("Sheet2").Select
Range("H11:H14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("H6").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("I11:I14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("I6").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B3:E3").Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Cut Destination:=Range("D10:G10")
Range("D10:G10").Select
Selection.Cut Destination:=Range("D11:G11")
Range("E11").Select
Selection.Cut Destination:=Range("D12")
Range("F11").Select
Selection.Cut Destination:=Range("D13")
Range("G11").Select
Selection.Cut Destination:=Range("D14")
Range("D11:D14").Select
Range("D14").Activate
Selection.Copy
Sheets("Sheet3").Select
Range("D2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B4:E4").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("E11:H11")
Range("F11").Select
Selection.Cut Destination:=Range("E12")
Range("G11").Select
Selection.Cut Destination:=Range("E13")
Range("H11").Select
Selection.Cut Destination:=Range("E14")
Range("E14").Select
ActiveCell.FormulaR1C1 = "3"
Range("E11:E14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("E2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B5:E5").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("F11:I11")
Range("G11").Select
Selection.Cut Destination:=Range("F12")
Range("H11").Select
Selection.Cut Destination:=Range("F13")
Range("I11").Select
Selection.Cut Destination:=Range("F14")
Range("F11:F14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("F2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B6:E8").Select
Application.CutCopyMode = False
Selection.Cut Destination:=Range("G11:J13")
Range("G12:J13").Select
Selection.Cut Destination:=Range("H12:K13")
Range("H13:K13").Select
Selection.Cut Destination:=Range("I14:L14")
Range("H11").Select
Selection.Cut Destination:=Range("G12")
Range("I11").Select
Selection.Cut Destination:=Range("G13")
Range("J11").Select
Selection.Cut Destination:=Range("G14")
Range("H12").Select
Selection.Cut Destination:=Range("H11")
Range("I12").Select
Selection.Cut Destination:=Range("H12")
Range("J12").Select
Selection.Cut Destination:=Range("I12")
Range("I12").Select
Selection.Cut Destination:=Range("H13")
Range("K12").Select
Selection.Cut Destination:=Range("H14")
Range("I14").Select
Selection.Cut Destination:=Range("I11")
Range("J14").Select
Selection.Cut Destination:=Range("I12")
Range("K14").Select
Selection.Cut Destination:=Range("I13")
Range("L14").Select
Selection.Cut Destination:=Range("I14")
Range("I14").Select
Sheets("Sheet2").Select
Range("A39").Select
Sheets("Sheet1").Select
Range("G11:G14").Select
Selection.Copy
Sheets("Sheet3").Select
Range("G2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("H11:H14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("H2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("I11:I14").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet3").Select
Range("I2").Select
ActiveSheet.Paste
End Sub
And then It Works on the First Worksheet i open, BUT When i go on a Diffrent Worksheet then i cant use it i get the error message "Runtime Error 1004 Method 'range of object'_Global' failed"