我需要复制Sheet 02的Activity列的内容并将其粘贴到我在编译过程中选择的其他sheet(Sheet 01)单元格中。 此处行号和列号可能会有所不同,但标题活动将相同,而未在报告的任何其他表中使用。 应重复此过程并从其他工作表(Sheets03,04,05等)复制粘贴。请找到格式 Monthly report format
答案 0 :(得分:1)
假设您知道如何插入模块。如果没有,你可以只记录一个宏,编辑宏并将我的代码粘贴在VBE中。
Sub Activity_collection()
' if there is no text of "Activity", remind to fill. xlWhole means fully match text.
Set find_cell = Sheet1.Cells.Find("Activity", , , xlWhole)
If find_cell Is Nothing Then
MsgBox "'Activity' title is missing in [sheet1], pls set the cells with 'Activity'"
Else
' get the row & col of 'activity' cell by find.
cell_row = find_cell.Row
cell_col = find_cell.Column
Dim DataRange As Range
Dim cel As Range
Dim brr()
Dim n As Long
Dim i As Integer
' copy the data you selected
On Error GoTo Err_handle
Set DataRange = Application.InputBox("Selection", "Choose the region you want to copy", , , , , , 8)
For Each cel In DataRange
n = n + 1
ReDim Preserve brr(1 To n)
brr(n) = cel.Value
Next
' Get the last cell with text
i = Sheet1.Cells(Rows.Count, cell_col).End(xlUp).Row
' fill new text in last bank cell
Sheet1.Cells(i + 1, cell_col).Resize(UBound(brr)) = Application.Transpose(brr)
Err_handle:
Exit Sub
End If
End Sub

答案 1 :(得分:-1)
请记录您的操作宏,然后您可能会得到一些想法。
我的意思是你可以学习excel-macro的工作方式。并调整代码以满足您的需求。