[英]Excel Merging Cells into one column on bulk data
I am having great difficulty with product data sent from a supplier that is in a bad layout. 我很难处理布局错误的供应商发送的产品数据。 I wanted the specification to be in separate columns for each product.
我希望每个产品的规范都放在不同的列中。 However, they have listed them in 2 columns making life difficult.
但是,他们将它们分为两列,这给生活带来了困难。
I have a formula that I want to use, however, I need to drag this down and skip rows that don't belong to that product. 我有一个要使用的公式,但是,我需要将其向下拖动并跳过不属于该产品的行。
For example: C2 to C8 and D2 to D8 consist of data for product 10000ES, the next product would need data from C9 to C18 and D9 to D18. 例如:C2至C8和D2至D8包含产品10000ES的数据,下一个产品将需要C9至C18和D9至D18的数据。
The formula I wish to use TO CONCATENATE as I wish to use this in my HTML website. 我希望在我的HTML网站中使用此公式来使用CON CONCATENATE。 But if I drag this down it would capture cells I do not want.
但是,如果我将其拖下,它将捕获不需要的单元格。
=CONCATENATE("<tr>",F2,"<tr>",F3,"<tr>",F4,"<tr>",F5,"<tr>",F6,"<tr>",F7,"<tr>",F8,"<tr>",F9,"<tr>",F10,"<tr>")
I think I can determine what you're after, based on the output I can make out in cell G2.. Try this: 我想我可以根据单元格G2中的输出确定您要执行的操作。
Sub TryThis()
Dim rng As Range, writeto As Range
Dim outpt As String
Set rng = ActiveSheet.Range("B1:D38") ' set this to cover the range down to the bottom
Set writeto = ActiveSheet.Range("G:G") ' this is the column to output to
For Each rw In rng.Rows
If rw.Cells(1, 2) <> "" Then
If rw.Cells(1, 1) = 1 Then
writeto.Cells(writeto.Rows.Count, 1).End(xlUp).Offset(1, 0) = outpt
outpt = ""
End If
outpt = outpt & "<tr>"
outpt = outpt & "<th>" & rw.Cells(1, 2) & "</th>"
outpt = outpt & "<td>" & rw.Cells(1, 3) & "</td>"
End If
Next
outpt = outpt & "<tr>"
writeto.Cells(writeto.Rows.Count, 1).End(xlUp).Offset(1, 0) = outpt
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.