vba training london - with statement

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft VBA Training and help » vba training london - "with" statement

vba training london - "with" statement

resolvedResolved · Low Priority · Version Standard

Petrus has attended:
Excel VBA Intro Intermediate course

"with" statement

what does the "with" statement do?

Edited on Mon 2 Jul 2007, 10:49

RE: "with" statement

Hi Petrus

The With Statement is very useful if you are using several statements in a section of code that apply to the same object.

It stops you having to fully qualify the object each time.

For example:

Worksheets("Accounts").Range("A1") .Font.Bold = True
Worksheets("Accounts").Range("A1") .Value = 47.5

Can be coded as below:

With Worksheets("Accounts").Range("A1")
.Font.Bold = True
.Value = 47.5
End With


Regards

Carlos

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Use VbNullString instead of

When needing to default a String variable back to it's default of "" use vbNullString as in the following example:

Sub ClearText()

Dim strEmpName As String

strEmpName = "John Smith"
MsgBox strEmpName

strEmpName = vbNullString
MsgBox strEmpName

End Sub

View all VBA hints and tips


Server loaded in 0.08 secs.