31 Now the blessed Apostle Paul in revealing the secret of these heavenly mysteries, most difficult to human comprehension, has preserved a clear enunciation and a carefully worded caution in order to show that these diverse gifts are given through the Spirit and in the Spirit (for to be given through the Spirit and in the Spirit is not the same thing), because the granting of a gift which is exercised in the Spirit is yet bestowed through the Spirit. But he sums up these diversities of gifts thus: Now all these things works one and the same Spirit, dividing to each one as He will. Now, therefore, I ask what Spirit works these things, dividing to each one according as He wills: is it He by Whom or He in Whom there is this distribution of gifts?
But if any one shall dare to say that it is the same Person which is indicated, the Apostle will refute so faulty an opinion, for he says above, And there are diversities of workings, but the same God Who works all things in all. So there is one Who distributes and another in Whom the distribution is vouchsafed. Yet know that it is always God Who works all these things, but in such a way that Christ works, and the Son in His working performs the Father's work. And if in the Holy Spirit you confess Jesus to be Lord, understand the force of that threefold indication in the Apostle's letter; forasmuch as in the diversities of gifts, it is the same Spirit, and in the diversities of ministrations it is the same Lord, and in the diversities of workings it is the same God; and again, one Spirit that works all things distributing to each according as He will.
And grasp the idea if you can that the Lord in the distribution of ministrations, and God in the distribution of workings, are this one and the same Spirit Who both works and distributes as He will; because in the distribution of gifts there is one Spirit, and the same Spirit works and distributes.
Source: On the Trinity (New Advent)