|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按钮1_Click()
arr = Sheets(4).UsedRange
Sheets(1).Select
For j = 2 To UBound(arr)
Cells(j, 1) = arr(j, 1)
brr = Sheets(2).UsedRange
x = WorksheetFunction.RandBetween(1, UBound(brr, 2))
y = WorksheetFunction.RandBetween(1, Sheets(2).Cells(Rows.Count, x).End(3).Row)
str1 = "名称:" & brr(1, x) & brr(y, x) & arr(j, 1) & Chr(10) & "地点: " & brr(1, x) & brr(y, x)
brr = Sheets(3).UsedRange
x = WorksheetFunction.RandBetween(1, UBound(brr, 2))
y = WorksheetFunction.RandBetween(1, Sheets(2).Cells(Rows.Count, x).End(3).Row)
str1 = str1 & Chr(10) & "品牌:" & brr(1, x) & Chr(10) & "型号: " & brr(y, x) & Chr(10) & Chr(10) & brr(1, x) & "的其他型号: "
str2 = ""
For i = 2 To UBound(brr)
If Len(brr(i, x)) > 0 Then
str2 = str2 & "," & brr(i, x)
End If
Next i
str1 = str1 & Chr(10) & Mid(str2, 2)
str1 = str1 & Chr(10) & brr(1, x) & arr(j, 1) & arr(j, 2)
Cells(j, 2) = str1
Next j
End Sub
|
|