我想在每个工作表的“R”列中找到最大值。如果MaxValue大于6,那么我将在“C”列中设置0到MaxValue的范围,增量为0.1。如果MaxValue小于6,我想将“C”列中的范围设置为0到6,增量为0.1。
Dim rng As Range
Set rng = ws1.Range("R2-R6000")
MaxValue = Application.WorksheetFunction.Max(rng)
If MaxValue > 6 Then
Lx = MaxValue
Else
Lx = 6
End If
我试图设置代码,但我对VBA很新,所以我不确定如何完成他的任务。提前谢谢!
答案 0 :(得分:0)
最好明确限定您的工作表,但这将是一个良好的开端。见评论
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.walk(src).next()[1]:
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
print("Found directory!")
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
copytree("/home/user/Desktop/WP_Test", "/home/user/Desktop/something")
答案 1 :(得分:0)
此代码适用于我:
Dim ws As Worksheet
Dim rng As Range
Dim MaxValue As Long
Dim NumberOfCells As Long
Dim i As Double
For Each ws In Worksheets
ws.Activate
Set rng = ws.Range("R2:R6000")
MaxValue = Application.WorksheetFunction.Max(rng)
If Not MaxValue > 6 Then
MaxValue = 6
End If
NumberOfCells = MaxValue / 0.1
Set rng = Nothing
i = 0
For Each rng In ws.Range("C1:C" & NumberOfCells + 1)
rng.Value = i
i = i + 0.1
Next rng
Next