我有两个工作表,一个在语言A中,一个在语言B中,具有相同的顺序(列和行)。现在我想将这些02工作表合并为一个双语。请帮帮我
答案 0 :(得分:1)
此代码将第一个和第二个工作表中的每个单元格与值之间的换行符组合在一起,并将结果文本放在第三个工作表上:
Sub CombineSheets(sh1 As Worksheet, sh2 As Worksheet, dest As Worksheet)
Dim lNumRows As Long, lNumCols As Long
Dim lRow As Long, lCol As Long
lNumRows = sh1.UsedRange.Rows.Count
If sh2.UsedRange.Rows.Count > lNumRows Then lNumRows = sh2.UsedRange.Rows.Count
lNumCols = sh1.UsedRange.Columns.Count
If sh2.UsedRange.Columns.Count > lNumCols Then lNumCols = sh2.UsedRange.Columns.Count
For lRow = 1 To lNumRows
For lCol = 1 To lNumCols
dest.Cells(lRow, lCol) = sh1.Cells(lRow, lCol) & vbCrLf & sh2.Cells(lRow, lCol)
Next lCol
Next lRow
End Sub
注意:这假定UsedRange
从两个工作表上的A1
开始。