用户定义的串联 [英] User defined concatenate

查看:18
本文介绍了用户定义的串联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展我的年度计划文档,以便提供更多信息。但是,目前我被困住了。

我当前的工作表布局如下:

我需要创建第二个工作表,该工作表将客户名称与其中包含"yes"值的每个列标题连接在一起,作为其单独的行。

示例1在新工作表中将变为:

Example 1 - Annuals
Example 1 - Xero Fee

我尝试了复制并粘贴宏,它基于对包含文本的行进行计数的数量列。这在新工作表中提供了所需数量的客户名称,但我无法计算出如何将此问题的"串联"部分包括到其中。

Public Sub CopyData()

    ' This routing will copy rows based on the quantity to a new sheet.
    Dim rngSinglecell As Range
    Dim rngQuantityCells As Range
    Dim intCount As Integer

    ' Set this for the range where the Quantity column exists. This works only if there are no empty cells
    Set rngQuantityCells = Range("G1", Range("G1").End(xlDown))

    For Each rngSinglecell In rngQuantityCells
        ' Check if this cell actually contains a number
        If IsNumeric(rngSinglecell.Value) Then
            ' Check if the number is greater than 0
            If rngSinglecell.Value > 0 Then
                ' Copy this row as many times as .value
                For intCount = 1 To rngSinglecell.Value
                    ' Copy the row into the next emtpy row in sheet2
                    Range(rngSinglecell.Address).EntireRow.Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
                    ' The above line finds the next empty row.

                Next
            End If
        End If
    Next
End Sub

推荐答案

如果您的目标是通过

.到这个(或那个):

.那么您要执行的操作称为取消透视


如何取消透视交叉表样式的数据:

您可以找到写在a question I answered a week ago上的步骤,还有更多detailed explanation and steps over here

如果您有任何问题,请告诉我!

是的,也许我以此为借口练习使用Screen2Gif,但它确实有助于演示观点!:-)

🇨🇦

这篇关于用户定义的串联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆