我处于图1所描述的情况,其中我有一个带有引用名称的单元格和一个带有一个或多个分号分隔的电子邮件的单元格,这些电子邮件与同一个引用相关联。我希望拆分包含多个电子邮件的单元格,然后连续堆叠它们并复制refence名称。是否可以使用Excel 2007中的VBA宏执行此操作?我知道"拆分列中的存在"命令,但我不知道如何自动移动行中的列并复制引用名称。提前谢谢。
答案 0 :(得分:1)
你走了:
Sub SplitColumnB()
Dim r As Range
Set r = [B2]
Do While r.Value <> ""
res = Split(r.Value, " ; ")
i = 0
For Each resStr In res
If i > 0 Then r.Offset(1).EntireRow.Insert xlDown
r.Offset(IIf(i > 0, 1, 0)).Value = resStr
r.Offset(IIf(i > 0, 1, 0), -1).Value = Right(resStr, Len(resStr) - InStr(resStr, "@"))
i = i + 1
Next
Set r = r.Offset(IIf(i > 0, i, 1))
Loop
End Sub
答案 1 :(得分:0)
尝试使用以下代码。将Sub test()
Dim Ref As String
Dim Eid As String
Dim RefR()
Dim EidR()
Rcnt = Sheets("Sheet1").Range("A65000").End(xlUp).Row
K = 0
L = 0
For i = 2 To Rcnt
Ref = Sheets("Sheet1").Range("A" & i).Value
Temp = Split(Sheets("Sheet1").Range("B" & i).Value, ";")
K = K + 1
ReDim Preserve RefR(1 To K)
RefR(K) = Ref
For j = LBound(Temp) To UBound(Temp)
If L <= UBound(Temp) Then
ReDim Preserve EidR(Rcnt, L)
L = UBound(Temp)
End If
EidR(K, j) = Temp(j)
Next j
Next i
RowValue = 2
For i = 1 To UBound(RefR)
For j = 0 To L
Sheets("Sheet1").Range("A" & RowValue).Value = RefR(i)
Sheets("Sheet1").Range("B" & RowValue).Value = Trim(EidR(i, j))
RowValue = RowValue + 1
Next j
Next i
End Sub
的所有实例替换为工作表的名称。
public class Server {
public static void main(String[] args) throws Exception {
ZMQ.Context ctx = ZMQ.context(1);
ZMQ.Socket socket = ctx.socket(ZMQ.REP);
socket.bind("tcp://192.168.56.1:5570");
System.out.println("Started");
while (!Thread.currentThread().isInterrupted()) {
byte[] request = socket.recv(0);
String string = new String(request);
System.out.println("Received request: ["+string+"].");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
socket.send("We got message".getBytes(), 0);
}
System.out.println("finished");
socket.close();
ctx.term();
}
}