WPS如何將一排單元格內容組合成隨機順序的文字

時間 2021-08-30 09:08:44

1樓:夜空裡的守望者

樓主,你好!這個是沒法使用函式公式解決的,還是建議樓主使用vba程式進行處理。(由於wps個人免費版不能使用vb功能,那就改用其他版本進行處理)

(一)vba程式**如下:(寫**不易,望笑納)

sub zuhe_***()

dim i1, i2, i3, myarray(100), str, rn

on error resume next

set mysheet1 = thisworkbook.worksheets("sheet1")

mysheet1.range("h1:h1000") = ""

for i1 = 1 to 1000

str = ""

randomize       '初始化隨機數

erase myarray   '初始化陣列

for i2 = 1 to 7

if mysheet1.cells(i1, i2) <> "" then

for i3 = 0 to 1000000

rn = int(rnd() * 7 + 1)  '生成1-7的隨機數

if ubound(filter(myarray, rn)) <> 0 then  '如果生成的隨機數不重複,則

myarray(i2) = rn

str = str & mysheet1.cells(i1, rn)

exit for

end if

next

end if

next

mysheet1.cells(i1, 8) = str

next

end sub

(二)程式的執行結果如下截圖:

【注】程式執行之前請做好資料備份,以免丟失。

2樓:小龍崇者

有些複雜,最好不要難為公式。

如何將EXCEL單元格中內容分門別類提取

第一個原數在a1格時 if if iserror find x20 a1,1 0,find x20 a1,1 0,mid a1,1,if iserror find x20 a1,1 0,find x20 a1,1 1 1,0 if if iserror find x40 a1,1 0,find x4...

Excel中怎麼合併單元格如何將多個單元格合併成單元格

興堅成後文 一 假設要將a1,b1,c1三個單元格內容合併起來,顯示在d1單元格,則可在d1單元格寫入公式 a1 b1 c1 或 concatenate a1,b1,c1 二 concatenate函式的定義 將幾個文字字串合併為一個文字字串。語法concatenate text1,text2,te...

如何將ecel單元格的內容拼接在一起a單元格和b單

一 假設要將a1,b1兩個單元格內容合併顯示在c1單元格,則可在c1單元格寫入公式 a1 b1 或 concatenate a1,b1 二 concatenate函式的定義 將幾個文字字串合併為一個文字字串。語法concatenate text1,text2,text1,text2,為 1 到 30...