Wauvel

Excel like a finance pro.

← The library

VBA · Control flow

With ... End With

Runs several statements against one object without repeating its name.

Very commonDifficulty 1100 · Proficient
Practice · 2 questions →

When to use it

With ... End With runs several statements against one object without repeating its name. Faster and easier to read.

The code

Code
With Range("A1")
  .Value = "Total"
  .Font.Bold = True
End With

Worked examples

  • Format a cell

    With Range("A1") .Value = "Total" .Font.Bold = True .Interior.Color = vbYellow End With Three properties set on one cell

    The dots hang off the With object.

  • Qualify a sheet

    With Worksheets("Data") lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row .Range("A1").AutoFilter End With Sheet-qualified calls without the name each time

    Explicit sheet references made short.

  • Page setup

    With ActiveSheet.PageSetup .Orientation = xlLandscape .FitToPagesWide = 1 End With Page setup in one block

    Slow properties, evaluated once.

Worth knowing

  • Nest With blocks for objects within objects.
  • Every member inside must start with a dot.
  • A With on a slow property like PageSetup avoids re-evaluating it.

Where it goes wrong

  • A line without the leading dot refers to something else entirely and does not error.
  • Cannot Exit or jump out of a With block cleanly.

Related

Learn the moves here — or let Wauvel run them on your numbers.

Meet your AI CFO →

One CFO-grade Excel tip a week

A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.