在非活动工作表上写入多个条目的更好结构



May听起来像是重复的,但我在研究中还没有看到完全相同的。

这是一个非常简单的问题(BigBen可能会在评论中非常巧妙地回答;(

我被告知.select.activate是要避免的,没有时间去寻找原因,所以也不知道如何使用它以及何时使用(我看着它,试着理解dw(。

什么比激活更好:

Sheets("Vendredi jour").Select
Cells(15, 38).Value = B
Cells(15, 39).Value = C
Cells(15, 40).Value = D
Cells(15, 41).Value = E
Cells(15, 42).Value = F
Cells(15, 43).Value = G

和每个条目上指定的工作表

Worksheets("Vendredi jour").Cells(15, 38).Value = B
Worksheets("Vendredi jour").Cells(15, 39).Value = C
Worksheets("Vendredi jour").Cells(15, 40).Value = D
Worksheets("Vendredi jour").Cells(15, 41).Value = E
Worksheets("Vendredi jour").Cells(15, 42).Value = F
Worksheets("Vendredi jour").Cells(15, 43).Value = G

Thx

使用With语句:

With Worksheets("Vendredi jour")
.Cells(15, 38).Value = B
.Cells(15, 39).Value = C
.Cells(15, 40).Value = D
.Cells(15, 41).Value = E
.Cells(15, 42).Value = F
.Cells(15, 43).Value = G
End With

确保每次Cells调用之前都有周期.

最新更新