- ©«¤l
- 835
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 915
- ÂI¦W
- 16
- §@·~¨t²Î
- Win 10,7
- ³nÅ骩¥»
- 2019,2013,2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-3
- ³Ì«áµn¿ý
- 2024-11-14
|
¥»©«³Ì«á¥Ñ luhpro ©ó 2011-6-25 23:27 ½s¿è
¨Ì¾Ú§Aªº»Ý¨D§ì¨ú«ü©w¦r¦êªºÄpµ²¦b©ó :
1. §ä¨ì "#" »P "$" ªº¦ì¸m,
2. ½T©w¾ºÙ³£¬O¥u¦³¨âÓ¦r, §_«h±N«ÜÃø½T»{¨ì©³¦W¦r¬O±qþ¸Ì¶}©l§ìªº
n§ä¨ì¬YÓ¦r¦êªº¦ì¸m Excel VBA ¦³Ó«ü¥O instr ¥i¥H¹F¦¨¦¹¥Øªº.
ȱo¤@ÃDªº¬O,
¤£½× instr ÁÙ¬O mid(left¡Bright¡Blen ¬Ò¦P) ¹ï©ó¤¤¤å¦r³£¬Oµø¬° 1 Ó¦rªºªø«×,
³o¦b§ì¨ú³øªí§Î¦¡ªº¤å¦r®É¬O«D±`¤£¾A¦X¥Îªº«ü¥O.
¨Ò¦p :
2011/06/25 ±i¤T 16:33:18
2011/06/25 §õ¥|®Q 16:55:21
Y¥Î mid(sstr,21,8) §ì²Ä¤@¦æ¥i¥H¥¿±`§ì¨ì®É¶¡ 16:33:18,
¦ý²Ä¤G¦æ«o·|§ì¦¨ 6:55:21 ,
©Ò¥H¤ñ¸û¦nªº°Ï¹j¤è¦¡·|¬O¦bn§ìªº¦r¦ê¥k¤è©ñ¤W¥Î¯S©w²Å¸¹,
¥Î instr §ì¨ú¸Ó²Å¸¹¦A©¹«e±À¤@©wªø«×.
µM¦Ó¦b c »y¨¥¤¤¤@Ó¤¤¤å¦r«h¬Oµø¬° 2 Ó¦rªºªø«×,
¦b¦¹Ãþ»Ý¨Dªº¨Ï¥Î¤W¯uªº¬O¤ñ Excel VBA ¤è«K¦h¤F.
©³¤U¬O§Ú·Q¨ìªºµ{¦¡ :- Sub nn()
- Dim sStr$, sColumn$
- Dim iI%, iBegin%, iMark%, iEnd%, iRows%, iRow%
- Dim iCol%, iCol1%, iNext%
-
- sColumn = "BJ"
- iCol1 = 0
- For iI = Len(sColumn) - 1 To 0 Step -1
- iMark = Asc(Mid(sColumn, iI + 1, 1)) - 64
- iCol1 = iCol1 + iMark * 26 ^ -(iI = 0)
- Next iI
- iRows = Cells(Rows.Count, "AO").End(xlUp).Row
- For iRow = 2 To iRows
- sStr = CStr(Cells(iRow, "AO").Value)
- iBegin = InStr(1, sStr, "#") + 1
- iNext = InStr(iBegin + 1, sStr, "#") + 1
- If iNext < iBegin Then iNext = iBegin
- iCol = iCol1
- Do Until iBegin > iNext
- iEnd = InStr(iBegin, sStr, "$") - 1
- Do Until iBegin > iEnd
- iMark = InStr(iBegin, sStr, "#") - 1
- If iMark > iBegin + 6 Then iMark = iEnd
- If iMark < iBegin Then iMark = iEnd
- Cells(iRow, iCol).Value = Trim(Mid(sStr, iBegin + 2, iMark - iBegin - 1))
- iBegin = iMark + 2
- iCol = iCol + 1
- Loop
- iNext = InStr(iBegin + 1, sStr, "#") + 1
- If iNext > iBegin Then iBegin = iNext
- Loop
- Next iRow
- End Sub
½Æ»s¥N½X |
|