数组中的excel更改格式的字符串 [英] Arrays in excel change format of string

查看:128
本文介绍了数组中的excel更改格式的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要分离图像中的数据。图像中的代码一旦达到分号和缩进就不分离。我想将这些单词分开到一张新表格上,以便我将搜索数组中的某些单词。

I have the data in the image I would like to separate. The code in the image doesn't separate once it gets to the semicolon and indentation. I would like to separate the words onto a new sheet so I'm about to search through the array for certain words.

感谢您的帮助!

推荐答案

以下代码不仅可以分割数据,还可以复制格式,这似乎也是您想要的。假设数据在列A中

The following code will not only split the data, but also copy over the formatting, which it seems you also wanted. Assumes data is in Column A

Option Explicit
Sub SplitWithFormat()
    Dim R As Range, C As Range
    Dim i As Long, V As Variant

Set R = Range("a1", Cells(Rows.Count, "A").End(xlUp))
For Each C In R
    With C
        .TextToColumns Destination:=.Offset(0, 1), DataType:=xlDelimited, _
        consecutivedelimiter:=True, Tab:=False, semicolon:=False, comma:=False, _
        Space:=True, other:=False

        .Copy
        Range(.Offset(0, 1), Cells(.Row, Columns.Count).End(xlToLeft)).PasteSpecial xlPasteFormats
    End With
Next C
Application.CutCopyMode = False

End Sub

这篇关于数组中的excel更改格式的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆