[英]Excel - Split apart a list
I have a list of about 300 items, that I need spaced out every 8 cells as opposed to being one after the other. 我有一个大约300个项目的列表,我需要每8个单元格间隔,而不是一个接一个。 I'm sure there is an easy way to do this, however my brain is failing me. 我确信有一种简单的方法可以做到这一点,但是我的大脑让我失望了。 I have a feeling my terminology is hurting hence why I can't find an answer. 我有一种感觉我的术语受到伤害,因此我找不到答案。
=IF(MOD(ROW()+7;8)=0;INDEX(A:A;INT(ROW()/8)+1);"")
假设数据从A1开始,并且从第1行使用公式(coulmn并不重要)。
Try below code 试试下面的代码
Sub Main()
Dim lastRow As Long
lastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To lastRow
If i = 1 Then
Cells(i, 5).Value = Cells(i, 1)
Else
Cells((i - 1) * 9, 5).Value = Cells(i, 1)
End If
Next
End Sub
Output 产量
Can you please post a screen shot or add some additional detail? 你能发布一个截图或添加一些额外的细节吗?
Two things come to my mind for possible solutions: 我想到了两个可能的解决方案:
1) Use Text to columns (if that is where you're going with this) or 1)使用文本到列(如果这是你要去的地方)或
2) Use a formula like =LEFT(A1, 10) in the 8th column and fill down (10 can be changed to whatever the first part of the string is that needs to be separated). 2)在第8列中使用类似= LEFT(A1,10)的公式并填充(10可以更改为需要分离的字符串的第一部分)。
Provide some additional info and I'll take another look! 提供一些额外的信息,我会再看看!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.