A surgical instrument, comprising: a housing; an endoscopic portion extending distally from the housing and defining a first longitudinal axis (A-A); a drive gear disposed at least partially within the housing, the drive gear rotatable about a drive gear axis (C-C) extending therethrough and being selectively movable along the drive gear axis (C-C) between a first position and a second position; a drive motor disposed in mechanical cooperation with the drive gear and being configured to rotate the drive gear; a shift motor disposed in mechanical cooperation with the drive gear and being configured to move the drive gear along the drive gear axis (C-C) between the first position and the second position; a shaft portion selectively connectable to a distal end of the endoscopic portion; an end effector (160, 1600) selectively connectable to a distal end of the shaft portion, the end effector (160, 1600) including a first jaw member and second jaw member, and the end effector defining a second longitudinal axis (B-B); a ring gear disposed at least partially within the housing and being disposed in mechanical cooperation with the end effector (160, 1600), whereby rotation of the ring gear causes rotation of at least a portion of the end effector (160, 1600) about the first longitudinal axis; and an actuator gear disposed at least partially within the housing and being disposed in mechanical cooperation with the end effector (160, 1600), whereby rotation of the actuator gear causes movement of at least one jaw member towards the other jaw member; wherein the drive gear is mechanically engaged with the ring gear when the drive gear is in a first position, and wherein the drive gear is mechanically engaged with the actuator gear when the drive gear is in a second position; and wherein the shaft portion is configured to accept a plurality of types of end effectors (160, 1600) and the surgical instrument further comprises at least one sensor (1700a, 1700b, 1700c) disposed in communication with the end effector (160, 1600) for helping to determine the type of end effector (160, 1600) that is engaged with the shaft portion; the surgical instrument further comprising at least one sensor disposed (1700a, 1700b, 1700c) in communication with the shaft portion for helping to determine the type of shaft portion that is engaged with the endoscopic portion (140;1400). a housing; an endoscopic portion extending distally from the housing and defining a first longitudinal axis (A-A); a drive gear disposed at least partially within the housing, the drive gear rotatable about a drive gear axis (C-C) extending therethrough and being selectively movable along the drive gear axis (C-C) between a first position and a second position; a drive motor disposed in mechanical cooperation with the drive gear and being configured to rotate the drive gear; a shift motor disposed in mechanical cooperation with the drive gear and being configured to move the drive gear along the drive gear axis (C-C) between the first position and the second position; a shaft portion selectively connectable to a distal end of the endoscopic portion; an end effector (160, 1600) selectively connectable to a distal end of the shaft portion, the end effector (160, 1600) including a first jaw member and second jaw member, and the end effector defining a second longitudinal axis (B-B); a ring gear disposed at least partially within the housing and being disposed in mechanical cooperation with the end effector (160, 1600), whereby rotation of the ring gear causes rotation of at least a portion of the end effector (160, 1600) about the first longitudinal axis; and an actuator gear disposed at least partially within the housing and being disposed in mechanical cooperation with the end effector (160, 1600), whereby rotation of the actuator gear causes movement of at least one jaw member towards the other jaw member; wherein the drive gear is mechanically engaged with the ring gear when the drive gear is in a first position, and wherein the drive gear is mechanically engaged with the actuator gear when the drive gear is in a second position; and wherein the shaft portion is configured to accept a plurality of types of end effectors (160, 1600) and the surgical instrument further comprises at least one sensor (1700a, 1700b, 1700c) disposed in communication with the end effector (160, 1600) for helping to determine the type of end effector (160, 1600) that is engaged with the shaft portion; the surgical instrument further comprising at least one sensor disposed (1700a, 1700b, 1700c) in communication with the shaft portion for helping to determine the type of shaft portion that is engaged with the endoscopic portion (140;1400).