By using expertatexcel.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

expertatexcel.com

 


if .Cells(i,j) ' referencing the with stmt

Save Time and make Code more readable.

if .Cells(i,j) ' referencing the with stmt

The dot "." or period can be used with a with statement.

The following code can be simplified


Some.Long.Object.Name.Cells(1,1) = "blah"
Some.Long.Object.Name.Cells(1,2) = "blah1"
Some.Long.Object.Name.Cells(1,3) = "blah2"
Some.Long.Object.Name.Cells(1,4) = "blah3"




can be made more readable with


With Some.Long.Object.Name
    .Cells(1,1) = "blah"
    .Cells(1,2) = "blah"
    .Cells(1,3) = "blah"
    .Cells(1,4) = "blah"
End With