1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| Sub CopyData(X1, X2, Y1, Y2)
' Macro recorded 14/10/2017 by Basile Boni
' **Copies and transposes cell range (X1:X2) into range (Y1:Y2) and then
' **clears out the contents of cell range (X1:X2)
' **The Screen Updating feature hides macro actions from the user
Application.ScreenUpdating = False
Range("X1:X2").Select
Selection.Copy
Range("Y1:Y2").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
' **Clear the contents of cell range (X1:X2)
Range("X1:X2").ClearContents
End Sub
Sub Copy_OrderEntry()
' Copy OrderEntry
' Macro recorded 14/10/2017 by Basile Boni
' ***Transfers user-input from the OrderEntry sheet into the Database sheet.
' ***Line 8 in the OrderEntry worksheet is arbitrarily chosen as a temporary
' ***transfer line (it is easier to move data as a single contiguous row)
' ***Transfer the Order number (cell H12), the Order date (cell I14), and the
' ***Supplier code number (cell D2) into cells B8,C8,D8
CopyData X1:="H12", X2:="H12", Y1:="B8", Y2:="B8"
CopyData X1:="I14", X2:="I14", Y1:="C8", Y2:="C8"
CopyData X1:="D2", X2:="D2", Y1:="D8", Y2:="D8"
' ***Transpose and transfer the 8 product numbers (J26:J33) into cells (E8:L8)
' ***The number of product lines can be increased to 15 if so desired
CopyData X1:="J26", X2:="J33", Y1:="E8", Y2:="L8"
' ***Transpose and transfer the 8 No. of Units Ordered (E26:E33) into cells (M8:T8)
' ***If the number of product lines is altered, also modify the two CopyData lines
CopyData X1:="E26", X2:="E33", Y1:="M8", Y2:="T8"
' ***Transfer row 8 (OrderEntry sheet) to row 3 (Database worksheet)
Worksheets("OrderEntry").Range("B8:T8").Cut Worksheets("Database").Range("A3")
' ***Insert a blank row in the database to prevent overwriting the current order
Worksheets("Database").Range("A3").EntireRow.Insert
End Sub |
Partager