如何根据搜索结果搜索和连接单元格

时间:2019-01-16 06:03:53

标签: excel vba

首先,我仍在学习excel VBA,似乎我想咬的东西超出了我在这里可以咀嚼的范围。我试图搜索我的问题,但找不到与我最接近的问题。

所以,我有一个csv数据集,如下所示:

date,"0000000000","SAO","32","Description","5000","REF"
date,"0000000000","SAO","32","Reversal from 
\nDescription","-5000","REF"
date,"0000000000","SAO","32","Description","10000","REF"

我希望数据看起来像这样:

date,"0000000000","SAO","32","Description","5000","REF"
date,"0000000000","SAO","32","Reversal from Description","-5000","REF"
date,"0000000000","SAO","32","Description","10000","REF"

手动是如此简单,但是有超过3000行需要更正,所以我需要使这个问题自动化。我尝试录制宏,但是没有用。

需要完成的步骤是: 1.搜索“ \ n” 我相信这可以做到吗?

set result = Find(What:="\n", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)    
  1. 复制搜索结果值
  2. 将搜索结果值粘贴到搜索结果之前的单元格中,使其看起来像这样
date,"0000000000","SAO","32","Description","5000","REF"
date,"0000000000","SAO","32","Reversal from \nDescription","-5000","REF"

date,"0000000000","SAO","32","Description","10000","REF"
  1. 删除空白单元格。
  2. 从“从\ n描述中撤消”中删除\ n,以便不再进行处理
  3. 再次从1开始。

我不知道如何执行此操作,请帮忙?

谢谢

0 个答案:

没有答案