File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,7 @@ This is an evolving document. Submit a pull request and start the conversation!
234
234
'do stuff with each worksheet
235
235
Next wks
236
236
```
237
+
237
238
* Prefer ` With...End With ` blocks to reduce repetition.
238
239
239
240
``` vb
@@ -245,3 +246,17 @@ This is an evolving document. Submit a pull request and start the conversation!
245
246
Set rng = .Range(.Cells( 1 , 1 ), .Cells(lngLastRow, 1 ))
246
247
End With
247
248
```
249
+
250
+ * Qualify ` Range ` objects with a ` Worksheet ` .
251
+
252
+ ``` vb
253
+ 'Bad
254
+ Set rng = Range(Cells( 1 , 1 ), Cells(lngIdx, 1 ))
255
+
256
+ 'Good
257
+ Set wks = ThisWorkbook.Worksheets( "Data" )
258
+ With wks
259
+ Set rng = .Range(.Cells( 1 , 1 ), .Cells(lngIdx, 1 ))
260
+ End With
261
+ ```
262
+
You can’t perform that action at this time.
0 commit comments