且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从行转置为列(VBA)

更新时间:2023-11-18 21:25:22

未经测试:

Dim c As Range, v

'find last-used cell in ColG
Set c = Cells(Rows.Count, "G").End(xlUp)

With c.offset(-3,0) 'starting with the cell 3 rows above the last-used cell...
    v = .resize(4,1).value      'get the value of the 4-row/1-col range below
    .resize(4,1).clearcontents  '...then clear that range
    .resize(1,4).value = Application.Transpose(v) 'place the values in a row
End with