简体   繁体   English

将合并后的单元格从其他工作表复制到摘要工作表中的一个单元格中

[英]Copy merged cells from other sheets into one cell in summary sheet

I have a workbook which has a Summary Sheet and updates with new sheets (with changing names, imported from a specified path) upon command. 我有一个工作簿,其中有一个摘要表,并根据命令更新了新表(具有更改的名称,从指定路径导入)。 In the summary sheet, I want to collect specific information present in the other sheets (all of them have the same template filled in with different information). 在摘要表中,我想收集其他表中存在的特定信息(它们都具有填充了不同信息的相同模板)。

For example, I want to copy the merged ranges B3:O3 in Sheet X , Sheet Y and Sheet Z into Cells A2, B2, C2 in Summary Sheet. 例如,我想将工作表X ,工作表Y和工作表Z的合并范围B3:O3复制到摘要工作表中的单元格A2, B2, C2中。

Questions: 问题:

A) How do I copy the info? A)如何复制信息?

B) How do I link the command to existing "Refresh Sheets" command which populates the workbook with updated information from a specified folder? B)如何将命令链接到现有的“刷新表”命令,该命令使用来自指定文件夹的更新信息填充工作簿?

Relatively new to VBA, so excuse me if question is basic. 对VBA来说相对较新,如果问题很基本,请原谅。 Thanks! 谢谢!

Assuming B3:O3 is a merged range you take the top left cell from each. 假设B3:O3是合并范​​围,则从每个区域的左上角单元格中选取。 Sub RefreshSheets represents your existing command and then there is a call within that code to the new sub GetInfo . Sub RefreshSheets代表您现有的命令,然后在该代码内调用新的Sub GetInfo

Like this 像这样

Option Explicit

Public Sub RefreshSheets()

    'Your current refresh code
     GetInfo  'call to other sub

End Sub

Public Sub GetInfo()

Dim wb As Workbook
Set wb = ThisWorkbook

With wb.Worksheets("Summary Sheet")

   .Range("A2") = wb.Worksheets("X").Range("B3")
   .Range("B2") = wb.Worksheets("Y").Range("B3")
   .Range("C2") = wb.Worksheets("Z").Range("B3")

End With


End Sub

If working with variable sheet names you could assign by position eg 如果使用可变工作表名称,则可以按位置分配,例如

Sheets(Sheets.Count) 

Or use a variable 或使用一个变量

Dim X As String
X = "X"

Sheets(X) 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VBA从工作表“ A”复制单元格到工作表“ B”中的合并单元格 - VBA to copy cell from Sheet“A” to merged cells in Sheet“B” 根据其他单元格中的值将行数据从一张纸复制到一张或多张纸 - copy row data from one sheet to one or more sheets based on values in other cells Excel VBA根据条件从一张纸复制到另一张纸的特定单元格 - Excel VBA copy from one sheet to other sheets specific cells based on criteria VBA将工作簿中所有工作表中选定范围内的已填充单元格复制到一个摘要工作表 - VBA Copy filled cells in selected range in all sheets within the workbook to one summary sheet 将单元格中的单元格复制到多张Excel - VBA中 - copy cells from one sheet into multiple sheets Excel - VBA 如何将特定范围单元格从多张纸复制到一张纸? - How to copy specific range cells from multiple sheets to one sheet? 将值从单独的合并单元格复制到一个合并单元格中,作为以逗号分隔的坐标 - Copy values from seperate merged cells into one merged cell as coordinates seperated by a comma 根据单元格值将多张纸中的行复制到一张纸中 - Copy rows from multiple sheets into one sheet based on a cell value 根据另一个单元格中的条件将单元格从一个工作表复制到另一个工作表 - Copy cells from one sheet to another based on criteria in another cell 从一个工作表复制单元格并粘贴到另一个工作表中到可变单元格 - Copy cells from one sheet and paste in another to a variable cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM