- ©«¤l
- 147
- ¥DÃD
- 46
- ºëµØ
- 0
- ¿n¤À
- 205
- ÂI¦W
- 0
- §@·~¨t²Î
- windows xp
- ³nÅ骩¥»
- office 2003
- ¾\ŪÅv
- 20
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2012-3-19
- ³Ì«áµn¿ý
- 2021-5-21
|
¥»©«³Ì«á¥Ñ Hsieh ©ó 2013-11-16 22:48 ½s¿è
¦^´_ 28# Hsieh
Dear Hsieh¤j¤j¡G
«D±`·PÁ±zªº¦^ÂСAì¨Ó¥ÎÂIÅÞ¿è¡A¨ÃÂǥѮ榡¹º³]©w§Y¥i°µ¨ì¡A·P¿E¡C
²Ä¤@¦¸¾Ç²ßVBA¡AÁÙ·d¤£²Mª¬ªpªº»¡¡A¯uªº«Ü·PÁ±zªº«ü¾É¡C§Úµy·Lקï¤@¤U¦p¤U»yªk¡G
¦ý¬O§Ú·Q¦A½Ð°Ý¤@Ó°ÝÃD¡A¦]¬°§Úªºì©lÀɮ׬O ¦r¦ê ¡A§Ú·Q§ï¦¨¼ÆÈ ±qDÄæ¨ìCOÄæ¡A§Úª¾¹D¥i¥H§ï Àx¦s®æ®æ¦¡¡A©Î¤â°Ê«ö¶sÂà¼ÆÈ¡A
¦ýÁÙ¬O§Ô¤£¦í·Q½Ð±Ð¤@¤U¦p¦ó¥i¥H¥Îvba§â¤å¦rÂন¼ÆÈ¡A¦pªþÀÉ¡A¦A½Ð¦h«ü±Ð¡A
¥t¥~¯u±o«Ü·PÁ±zÅý§Úª¾¹DVBA±o¦nª±¦³½ì¡C- Sub Replace_Blank()
- Columns("A:A").Select
- Selection.Insert Shift:=xlToRight
- Selection.Insert Shift:=xlToRight
- Range("A1").Select
- ActiveCell.FormulaR1C1 = "user"
- Range("B1").Select
- ActiveCell.FormulaR1C1 = "password"
- Dim E As Range
- For Each E In Range("f:f").SpecialCells(xlCellTypeConstants)
- E.Value = "'" & Replace(E, ",", "")
- Next
- With [H:BC]
- .Replace "*,*", "", xlWhole '²M°£½Æ¿ï
- End With
- With [H:BC] '1~48ÃDªºÄæ¦ì
- .Replace 1, "3@", xlWhole '±N1¥Î¤@Ó¤£±`¥Î²Å¸¹¨ú¥N
- .Replace 2, 1, xlWhole '±N2¥Î1¨ú¥N
- .Replace 3, 2, xlWhole '±N3¥Î2¨ú¥N
- .Replace "3@", 3, xlWhole '±N¤£±`¥Î²Å¸¹¥Î3¨ú¥N
- End With
- Dim A As Range, Ar(), B As Range
- Set Upw = CreateObject("Scripting.Dictionary") '±b±K
- Set dic = CreateObject("Scripting.Dictionary") '°Ñ·Ó
- fs = ThisWorkbook.Path & "\replace_rule.txt" 'TEXTÀɮצì¸m
- Close #1 'Y¤w¸g¶}±Ò´N¥ýÃö³¬
- With Sheets("Sheet0")
- Open fs For Input As #1
- Do Until EOF(1)
- Line Input #1, mystr
- If InStr(mystr, ",") > 0 Then
- s = InStr(mystr, "(")
- n = InStr(s, mystr, ")")
- mystr = Mid(mystr, s + 1, n - s - 1)
- For Each C In Split(mystr, ",")
- Set A = .Rows(1).Find(C)
- ReDim Preserve Ar(i)
- Ar(i) = Split(A.Address, "$")(1)
- i = i + 1
- Next
- For Each p In Ar
- dic(p) = Ar '°O¿ý¤½¦¡°Ñ·ÓÄæ¦ì
- Next
- Erase Ar: i = 0
- End If
- Loop
- Close #1
- With Sheets("Sheet1")
- For Each A In .Range(.[A2], .[A2].End(xlDown))
- Upw(CStr(A)) = Array(A.Offset(, 3).Value, A.Offset(, 2).Value) '°O¿ý±b±K
- Next
- End With
- '¨ú¥N½Æ¿ï¦ì¸m
- Set A = .Range(.[H2], .Cells(.Rows.Count, "CQ").End(xlUp)).Find("*,*")
- If Not A Is Nothing Then
- Do
- ay = Split(A, ",")
- For i = 0 To UBound(ay)
- ReDim Preserve Ar(i)
- Ar(i) = Val(ay(i))
- Next
- A.Value = Round(Application.Average(Ar), 0)
- Erase Ar
- Set A = .Range(.[H2], .Cells(.Rows.Count, "CQ").End(xlUp)).Find("*,*", A)
- Loop Until A Is Nothing
- End If
- i = 0
- .Select
- For Each A In .Range(.[F2], .Cells(.Rows.Count, "F").End(xlUp))
- A.Offset(, -5).Resize(, 2) = Upw(CStr(A)) '¶ñ¼g±b±K
- r = A.Row
- For Each B In .Range(.Cells(r, "H"), .Cells(r, "CQ"))
- If B = "" Then '§ä¨ìªÅ®æ
- ay = dic(Split(B.Address, "$")(1))
- If Not IsEmpty(ay) Then '¸ÓÀx¦s®æ¦³³Q¤½¦¡¤Þ¥Î
- For i = 0 To UBound(ay)
- If .Range(ay(i) & r) <> "" Then '¤Þ¥Îªº°Ñ·Ó«DªÅ¥Õ¤~p¤J°}¦C
- ReDim Preserve Ar(j)
- Ar(j) = ay(i) & r
- j = j + 1
- End If
- Next
- If j > 0 Then B.Value = Round(Application.Evaluate("Average(" & Join(Ar, ",") & ")"), 0)
- Erase Ar
- j = 0
- End If
- End If
- Next
- Next
- End With
- Cells.Select
- Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
- "=(COUNTBLANK($A1:$CQ1)>0)*(COUNTA($A1:$CQ1)>0)"
- Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
- With Selection.FormatConditions(1).Interior
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorAccent6
- .TintAndShade = 0.399945066682943
- End With
- Selection.FormatConditions(1).StopIfTrue = True
- End Sub
-
½Æ»s¥N½X [attach]16355[/attach] |
|