各位高手帮忙看下,为什么我生成的结果会有空行?是在不清楚什么原因。附件太大,发不了,如需要我另发。谢谢了。
SubNewID() Worksheets("s1_c1").Activate Range("p4:p2203").Select Selection.ClearContents Application.ScreenUpdating= False Application.Calculation= xlCalculationManual Dimi, j, k, l, m, n As Integer Dimsku As String 'use it tostore sku id Dimrnd1 As Double Dimarr_space(), arr_skuid() arr_space()= Sheet1.Range("e4:h9003") arr_skuid()= Sheet1.Range("j4:j2203") i= UBound(arr_skuid()) 'daily skunumber,2200 j= UBound(arr_space()) 'seasonal skunumber, 9000 Fork = 1 To i Randomize rnd1 = Rnd() For l = 1 To j 'generate random numb,for each one, wecirculate and find an id If arr_space(l, 1) > 0 And rnd1> arr_space(l, 3) And rnd1 < arr_space(l, 4) Then sku = arr_space(l, 2) arr_skuid(k, 1) = sku arr_space(l, 1) = 0 Exit For End If 'Next m Next l 'write Sheet1.Cells(k + 3, 16) = arr_skuid(k, 1) Nextk Application.Calculation= xlCalculationAutomatic Application.ScreenUpdating= True EndSub
|