我需要创建一定数量的工作表,具体取决于List中的名称数量。工作表需要与列表/数组中每个单元格中的字符串值具有相同的名称。到目前为止,我的代码无效:
/**
* Returns a random item from an array based on a weighted value.
* @param array $array ['foo' => 70, 'bar' => 30] Foo has a 70 percent chance of being returned
* @return int|string
*/
public function randomize(array $array)
{
$sumOfWeights = array_sum($array);
$random = rand(1, $sumOfWeights);
foreach ($array as $name => $weight) {
$random -= $weight;
if ($random <= 0) {
return $name;
}
}
}
谢谢!
答案 0 :(得分:2)
这不起作用吗?
For Each rng In VersandRange
Worksheets.Add
ActiveSheet.Name = rng.Value
Next