如何获取单元格的格式和填充以及值?我正在将一些数据从一个工作表传输到另一个工作表并需要格式,但此代码仅获取值。有什么建议吗?
Dim i As Integer
Dim j As Integer
Dim r As Integer
Dim l As Integer
Dim c As Integer
r = 2 'row No to start at on original data
l = 2 'row to start at for Mitigation
Sheets(2).Activate
Range("D2").Select
j = 2 ' row
Do Until IsEmpty(ActiveCell) ' Set Do loop to stop when last row is reached.
c = 4 ' column
Do Until IsEmpty(ActiveCell) ' Set Do loop to stop when an empty cell is reached.
Sheets(6).Cells(l, 3) = Sheets(2).Cells(j, c) 'Description
Sheets(6).Cells(l, 4) = Sheets(2).Cells(j, 1) 'H ID
Sheets(6).Cells(l, 5) = Sheets(2).Cells(j, 2) 'S ID
ActiveCell.Offset(0, 1).Select
c = c + 1
l = l + 1
Loop
r = r + 1
j = j + 1
ActiveCell.Offset(1, 4 - c).Select
Loop
答案 0 :(得分:0)
您可能会尝试复制/粘贴:
Sheets(2).cells(j, c).Copy Destination:=Sheets(6).Cells(l, 3)
此代码将复制工作表2中行“j”和列“c”中的单元格,并将其粘贴到工作表6,行“l”列“3”