<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
  <channel>
    <title>VBA hints and tips</title>
    <link>https://www.stl-training.co.uk/hints-tips-vba-21.html</link>
    <description>Software application hints and tips from our Microsoft Qualified trainers</description>
    <language>en</language>
    <pubDate>Tue, 21 Apr 2026 05:44:40 GMT</pubDate>
    <lastBuildDate>Tue, 21 Apr 2026 05:44:40 GMT</lastBuildDate>
    <docs>https://www.stl-training.co.uk/rss-feeds.php</docs>

    <item>
      <title>Use VbNullString instead of</title>
      <description>When needing to default a String variable back to it's default of &quot;&quot; use [b]vbNullString[/b] as in the following example: 

Sub ClearText()
    
    Dim strEmpName As String

    strEmpName = &quot;John Smith&quot;
    MsgBox strEmpName

    strEmpName = vbNullString
    MsgBox strEmpName

End Sub</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-480</link>
      <pubDate>Fri, 08 Dec 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-480</guid>
    </item>

    <item>
      <title>Stop Screen Flickering When Running Code</title>
      <description>Running VBA code may cause the screen to flicker as the monitor is the slowest part of the program and cannot keep up with the very fast changes taking place.  

To switch off the screen until the program is run enter the following code line:

[b]Application.ScreenUpdating = False[/b]

The screen comes on automatically on completion of the program.</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-476</link>
      <pubDate>Fri, 01 Dec 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-476</guid>
    </item>

    <item>
      <title>Stuck in a Code Loop</title>
      <description>If you ever get stuck in an infinite code loop when programing in VBA use 

[b]CTRL+BREAK[/b]

to exit the procedure 
</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-395</link>
      <pubDate>Fri, 24 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-395</guid>
    </item>

    <item>
      <title>Display Text In a Msgbox On Multiple Lines</title>
      <description>When displaying text in a [b]MsgBox[/b] you may need to show it over multiple lines. To do this use:

[b]vbCrLf[/b]

As in:

MsgBox &quot;The System has detected an error.&quot; &amp; [b]vbCrLf[/b] &amp; &quot;Contact your System Administrator&quot;

The first sentence in quotes will appear  above the second in the MsgBox.</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-405</link>
      <pubDate>Fri, 24 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-405</guid>
    </item>

    <item>
      <title>Empty The Clipboard with CutCopyMode</title>
      <description>After each Copy/Paste operation in VBA, you should use the following line of code to empty the clipboard. This ensures that    the computer memory doesn't overload:

ActiveSheet.Paste
[b]Application.CutCopyMode = False [/b]

</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-416</link>
      <pubDate>Fri, 24 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-416</guid>
    </item>

    <item>
      <title>Suspend DisplayAlerts in VBA</title>
      <description>To stop Excel asking you things like &quot;Do you want to delete this file...&quot;, use the following line of code at the beginning of the relevant VBA procedure:

[b]Application.DisplayAlerts = False[/b]

At the end of the procedure make sure you use the following code to reactivate Display Alerts:

[b]Application.DisplayAlerts = True [/b]</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-417</link>
      <pubDate>Fri, 24 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-417</guid>
    </item>

    <item>
      <title>Use GoTo to Select A Cell With VBA</title>
      <description>To select a certain cell on a Worksheet you can use:

[b]Application.Goto Reference:=Range(&quot;V300&quot;)[/b]

or more simply

[b]Range(&quot;V300&quot;).Select[/b]

If, on the other hand, you want the selected cell to be the top/left cell on the screen you use:

[b]Application.Goto Reference:=Range(&quot;V300&quot;), Scroll=True [/b]</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-418</link>
      <pubDate>Fri, 24 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-418</guid>
    </item>

    <item>
      <title>Add A New Sheet at the end of the Workbook</title>
      <description>To add a new sheet at the end of the workbook you need to count the sheets in the workbook using:

[b]Sheets.Count [/b]

Then use this value as the rank of the sheet after which you want to add the new sheet:

[b]Sheets.Add After:=Sheets(Sheets.Count)[/b]</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-419</link>
      <pubDate>Fri, 24 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-419</guid>
    </item>

    <item>
      <title>Count the Rows and Columns in a Selection</title>
      <description>If you need to count the number of rows or columns in a worksheet use the following code:

[b]Selection.Rows.Count[/b] - Returns the number of rows in the selection

[b]Selection.Columns.Count[/b] - Returns the number of columns in the selection

[b]Selection.CurrentRegion.Rows.Count[/b] - Returns the number of rows in the current region of the selection</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-421</link>
      <pubDate>Fri, 24 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-421</guid>
    </item>

    <item>
      <title>Good coding practice</title>
      <description>It is important that you always comment the VBA code that you write.  By doing this it will make the code much easier to read, as both yourself and other people will be able to see what the code is doing or meant to be doing.  This is very important if there is more than one person who writes code in the company as you may have different styles of coding and may not really understand what the other person is trying to do.  Also if you write some code and then do not touch it for a year or so you may actually forget what it is meant to be doing.  so it is very important to include comments throughout your code and try and make sure that they are as useful as possible</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-388</link>
      <pubDate>Thu, 23 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-388</guid>
    </item>

    <item>
      <title>Stop Display Alerts In Excel</title>
      <description>When creating or deleting a Worksheet in Excel you don't want Excel to inform you &quot;A file already exists.....&quot; Or &quot;Do you want to save this file...&quot;.

To stop these alerts happening use the following line of code:

[b]Application.DisplayAlerts = False[/b]

After the Create or Delete routine use:

[b]Application.DisplayAlerts = True[/b]</description>
      <link>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-335</link>
      <pubDate>Tue, 07 Nov 2006 00:00:00 GMT</pubDate>
      <guid>https://www.stl-training.co.uk/hints-tips-vba-21.html#tip-335</guid>
    </item>
  </channel>
</rss>