从标签之间提取

时间:2016-06-25 09:18:30

标签: html excel excel-vba excel-formula excel-2007 vba

我有以下格式的电子邮件地址,放在Excel 2007的一列中,如下所示:

<br>

某些单元格具有不同的<td class="Normal">street name 1<br>city, state postal<br>country</TD> 标记,如下所示:

<td class="Normal">street name1<br>street name 2<br>city

我可以使用Excel“text to columns”函数提取最后两个标记但是在列中提取时转换不一致,并且将每个列对齐到正确的位置需要永久。

列表都有“,”来区分街道地址,我可以使用“text-to column”功能在“,”之前提取所有数据,然后处理第一个子集以获取数据,就像这样:

<br>

有没有办法从两个第一个<br>标记或脚本中提取以计算<br>标记的数量,然后使用脚本提取每组<br>标记在不同的列中,因为有些标记有<br>个标记,而其他标记有两个contentType : "application/json"标记。

1 个答案:

答案 0 :(得分:2)

我想这就是你要找的东西:

     V = [195.1126 169.3114 62.4193,28.2725 23.0191 9.3104,52.9536 -5.7639 1.7606];
 c = V(1:3); % The centroid
 l = V(4:6); % Axis Length
 phi = -V(7:9); % Angles
 E = zeros(512,512,85); % initialize Elipse matrix
 R = rotx(phi(1))*roty(phi(2))*rotz(phi(3)); % Create rotation matrix around phi
 %%
 [X,Y,Z] = meshgrid(1:size(E,2),1:size(E,1),1:size(E,3)); % Create a Grid
 XYZr = ([X(:)-c(1),Y(:)-c(2),Z(:)-c(3)])*R; % rotate Grid and centralize around centroid
 %% Calculate the elipse equation
 inx = (((XYZr(:,1)))./l(1)); % 
 iny = (((XYZr(:,2)))./l(2));
 inz = (((XYZr(:,3)))./l(3));
 ind = [inx,iny,inz];

 E(:) = sum(ind.^2,2)<1;
 %% Display
 figure; imagesc(E(:,:,62));
 figure; imagesc(squeeze(E(:,195,:)));
 figure; imagesc(squeeze(E(170,:,:)));

参见图片以供参考: enter image description here

编辑#1:根据我们的讨论进行更改 的 ------------------------------------------------------------------------

Sub Demo()
    Dim str() As String, tempStr As String
    Dim lastRow As Long, i As Long, colStart As Long, r As Long

    lastRow = Cells(Rows.Count, "A").End(xlUp).Row    '-->get last row with data
    For r = 1 To lastRow
        tempStr = Range("A" & r).Value
        colStart = 2
        str = Split(tempStr, "<br>")    '-->split string on tag <br>
        For i = 1 To UBound(str) - 1
            Cells(r, colStart) = str(i)
            colStart = colStart + 1
        Next
    Next r
End Sub