Excel公式,在它下面的每一行添加标题
所以我得到了这样的东西(全部在A列,单独的行):
Title01
atext atext atext atext atext
btext btext btext btext btext
ctext ctext ctext ctext ctext
title02
atext atext atext atext atext
btext btext btext btext btext
ctext ctext ctext ctext ctext
title03
atext atext atext atext atext
btext btext btext btext btext
ctext ctext ctext ctext ctext
而我需要解决scheme来改变它是这样的:
Title01
Title01 – atext atext atext atext atext
Title01 – btext btext btext btext btext
Title01 – ctext ctext ctext ctext ctext
Title02
Title02 – atext atext atext atext atext
Title02 – btext btext btext btext btext
Title02 – ctext ctext ctext ctext ctext
Title03
Title03 – atext atext atext atext atext
Title03 – btext btext btext btext btext
Title03 – ctext ctext ctext ctext ctext
** Basicaly – 为每列添加前缀(的标题)一行,直到下一个标题…有没有什么想法,我怎么能做到这一点约3000线totaly,他们不是每个标题下相同…
谢谢!**
- 进入单元格
B1
放置公式=A1
- 进入单元格
B2
,公式=IF(MID(A2, 1,5)="Title", A2, B1)
- 将该公式填入数据的最后一行。
- 在单元格
C1
,公式=IF(MID(A1, 1,5)="Title", A1, B1 & " - " & A1)
- 填好。
现在,您可以在列C中find所需的内容。您可以复制,然后粘贴“特殊”值来摆脱公式。
Sub Tester() Dim c as Range, ttl as string for each c in selection.cells if lcase(c.value) like "*titletext*.txt" then ttl = c.value else if len(c.value)>0 and len(ttl)>0 then c.value = ttl & " - " & c.value end if end if next c End sub
你不能在一个单元格中input“推”到其他单元格中。 其他单元格必须是引用回您的标题的公式。 所以你会有类似的东西
A 1 Title01 2 =A1&"atext atext atext atext atext" 3 =A1&"btext btext btext btext btext"
依此类推。