[英]combine different cells to same row
I want each record on the same row: 我希望每个记录都在同一行上:
Row 1 Column 1: Parcel Number, Row 1 Column 2: Owner Name, Row 1 Column 3: Address
SAMPLE : 样本:
Parcel Record 21033540290000 Owner Doe, John M, SR. 包裹记录21033540290000所有者Doe,John M,SR。 & Jane H;
&Jane H; TRS Address 2116 W Wall St Parcel Record 21033540450000 Owner Brown, MARSHA & GREEN, MARIE;
TRS地址2116 W Wall St包裹记录21033540450000所有者Brown,MARSHA&GREEN,MARIE; JT Address 2131 W Harvard Ave Parcel Record 21033230450000 Owner Smith, MICHELLE K Address 4281 S Yale Ave
JT地址2131 W Harvard Ave包裹记录21033230450000 Owner Smith,MICHELLE K地址4281 S Yale Ave
I would like the format to be on the same row with 3 columns: 我希望格式在3列的同一行上:
21033540290000 Doe, John M, SR. & Jane H; TRS 2116 W Wall St
21033540450000 Brown, MARSHA & GREEN, MARIE; JT 2131 W Harvard Ave
21033230450000 Smith, MICHELLE K 4281 S Yale Ave
Then delete the Owner and Address rows after the data is copied to the same row as the Parcel number. 将数据复制到包裹编号所在的同一行后,然后删除所有者和地址行。
Have recorded a macro, but have problem looping & referencing cells and rows. 记录了一个宏,但是在循环和引用单元格和行时遇到了问题。 Sub FormatRows() ' ' FormatRows Macro ' Formats to same row ' ' Keyboard Shortcut: Ctrl+f
子FormatRows()''FormatRows宏'格式化为同一行''键盘快捷键:Ctrl + f
Range("B1").Select
Selection.Cut
Range("A1").Select
ActiveSheet.Paste
Range("B2").Select
Selection.Cut
Range("B1").Select
ActiveSheet.Paste
Range("B3").Select
Selection.Cut
Range("C1").Select
ActiveSheet.Paste
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
Range("B2").Select
Selection.Cut
Range("A2").Select
ActiveSheet.Paste
Range("B3").Select
Selection.Cut
Range("B2").Select
ActiveSheet.Paste
Range("B4").Select
Selection.Cut
Range("C2").Select
ActiveSheet.Paste
Rows("3:3").Select
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
Range("B3").Select
Selection.Cut
Range("A3").Select
ActiveSheet.Paste
Range("B4").Select
Selection.Cut
Range("B3").Select
ActiveSheet.Paste
Range("B5").Select
Selection.Cut
Range("C3").Select
ActiveSheet.Paste
Rows("4:4").Select
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
Range("B4").Select
End Sub 结束子
' How can I get this to loop thru a couple thousand rows? '我怎样才能使它循环通过几千行?
Thank you! 谢谢!
This would require string processing 这将需要字符串处理
Step 1: Find the number part: 步骤1:找到数字部分:
Dim strTemp As String
Dim strChar As String
strTemp = "Parcel Record 21033540290000 Owner Doe, John M, SR. & Jane H; TRS Address 2116 W Wall St "
flag = True
i = 1
On Error GoTo lblEnd:
While flag = True
strChar = Strings.Mid(strTemp, i, 1)
If IsNumeric(strChar) Then
'your code here
End If
i = i + 1
Wend
lblEnd:
Err.Clear
Step 2: Find "," and ":". 步骤2:找到“,”和“:”。 Just change the if part of the previous code:
只需更改前面代码的if部分:
If strChar = "," Then
'your code here
End If
and this: 和这个:
If strChar = ":" Then
'your code here
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.