045這3個數(shù)字我希望能用excel輸入A1以后自動在B1算出這049號碼出3個號的組合,。045,054,405,450,504,540,要有逗號分割開來。就是彩票里面的排列三,,我有軟件,,但是數(shù)據(jù)量太大,很費時間,,希望能用excel節(jié)約大概1-2個小時算法,。.另外要是一個單元格有10個這種3個數(shù)字,又怎么計算,?比如在A1單元格中有:045,269,078,046,058,359,236,469,039,789這10個自動在B1中算出他們出3個號的組合045,054,405,450,504,540,269,296,629,692,926,962,078,087,708,780,807,870, 046,064,406,460,604,640,058,085,508,580,805,850,359,395,539,593,935,953,236,263,326,362,623,632,469,496,649,694,946,964,039,093,309,390,903,930,789,798,879,897,978,987,如何計算?請高手指點,,謝謝。 用自定義函數(shù)get_array試試,最終結(jié)果如圖:
step1.工具->宏->安全性->低->保存退出(不然用不了自定義函數(shù)) step2.打開該文件,工具->宏->Visual Basic 編輯器 --------------------------------------------------------------------------------- 我用的是03版的Excel,如果你用07版,也按照上面說的這樣設(shè)置一下吧,你應(yīng)該也可以找到打開07版Excel的Visual Basic 編輯器的方法 --------------------------------------------------------------------------------- step3.在Visual Basic 編輯器里->插入->模塊 step4.把以下代碼拷進(jìn)編輯器右邊空白處 Function get_array(x) comma_count = Len(x) - Len(Replace(x, ",", "")) Dim A(65536) get_array = "" temp = x For i = 1 To comma_count + 1 A(i) = Left(temp, 3) first_letter = Left(A(i), 1) mid_letter = Mid(A(i), 2, 1) last_letter = Right(A(i), 1) get_array = get_array & IIf(i = 1, "", ",") & first_letter & mid_letter & last_letter & "," & first_letter & last_letter & mid_letter & "," _ & mid_letter & first_letter & last_letter & "," & mid_letter & last_letter & first_letter & "," & last_letter & first_letter & mid_letter & "," _ & last_letter & mid_letter & first_letter If i <> comma_count + 1 Then temp = Mid(temp, 5, Len(temp)) Next End Function 如圖:
這樣就可以定義函數(shù)get_array了,調(diào)用這個函數(shù)時跟其他Excel帶的函數(shù)一樣,如在B2輸入get_array(A2)就可以得到所需結(jié)果了:)
|