String 让excel将拆分字符串放在一起

String 让excel将拆分字符串放在一起,string,excel,text,split,String,Excel,Text,Split,我试图让excel把一系列没有系统格式化的文本字符串放在一起,这样它们就可以在数据表上拆分成不同的行 我知道这可能已经在其他地方解决了,对此我很抱歉,但我正在努力描述这个问题,我不能在上面发布图片,但基本上它是 列1,其中包含条目列表,以及 第2列,包含分布在2行或更多行上的文本字符串 是否可以编写某种公式或宏来检查第一列,然后将第二列中的所有条目缝合在一起,直到在第一列中找到新条目?我有一种感觉,它可能会使用一些循环的东西与索引函数,但我甚至不知道从哪里开始 谢谢, 迈克迈克,给我个机会

我试图让excel把一系列没有系统格式化的文本字符串放在一起,这样它们就可以在数据表上拆分成不同的行

我知道这可能已经在其他地方解决了,对此我很抱歉,但我正在努力描述这个问题,我不能在上面发布图片,但基本上它是

  • 列1,其中包含条目列表,以及
  • 第2列,包含分布在2行或更多行上的文本字符串
是否可以编写某种公式或宏来检查第一列,然后将第二列中的所有条目缝合在一起,直到在第一列中找到新条目?我有一种感觉,它可能会使用一些循环的东西与索引函数,但我甚至不知道从哪里开始

谢谢, 迈克

迈克,给我个机会

子附录值()

'子程序设计为循环代码,当有空值和a列时,它将获取B列中的值并附加到其上方的行,然后删除该行

将行设置为整数

行=1

'此代码以第一行开始,但可以随意更改

执行此工作簿.Sheets(“sheet1”).Cells(第2行)之前的操作。Value=“”

'循环语句被设计为继续循环,直到在第二列中的值中有空值为止

如果此工作簿.Sheets(“sheet1”).Cells(第1行).Value=“”则

ThisWorkbook.Sheets(“sheet1”).Cells(第1行,第2行)。Value=ThisWorkbook.Sheets(“sheet1”).Cells(第1行,第2行)。Value和ThisWorkbook.Sheets(“sheet1”).Cells(第2行)。Value

行(行)。删除

否则

'else语句是必需的,因为在删除后,通过减少总行数存在隐含循环

行=行+1

如果结束

环路

端接头

    Sub appendValues()
'The sub is designed to loop through code and when ever there is a null value and column a it will take the value of what is in column B and appended to the row above it and delete the row.

Dim row As Integer

row = 1

'This code starts with row one but this can be changed at will.

Do Until ThisWorkbook.Sheets("sheet1").Cells(row, 2).Value = ""

'loop statement is designed to continue to Loop until there is a null value inside of you the value in the second column.

If ThisWorkbook.Sheets("sheet1").Cells(row, 1).Value = "" Then

ThisWorkbook.Sheets("sheet1").Cells(row - 1, 2).Value = ThisWorkbook.Sheets("sheet1").Cells(row - 1, 2).Value & ThisWorkbook.Sheets("sheet1").Cells(row, 2).Value

Rows(row).Delete

Else

'else statement is needed because there is an implied looping by decreasing the total number of rows after the delete.

row = row + 1

End If

Loop

End Sub

迈克为你做了这件事??还是你需要更多的帮助?