Hi Don,
The code below appears with double spacing in my posting window. It's the last procedure in Module1 of the attached workbook.
Private Function GetSheet(ByVal SheetName As String) As Worksheet
' 02 Jun 2019
Dim Ws As Worksheet
Set Ws = ActiveSheet ' remember the ActiveSheet
Application.ScreenUpdating = False
On Error Resume Next
Set GetSheet = Worksheets(SheetName) ' error if sheet doesn't exist
If Err Then
' create the sheet
Set GetSheet = Worksheets.Add(After:=Worksheets(Worksheets.Count))
ActiveSheet.Name = SheetName
Ws.Activate ' re-activate the original ActiveSheet
End If
Application.ScreenUpdating = True
End Function
Below is the same code between code tags. The tags were entered first, then the tag's text selected and the code pasted to repalce it. Prior to uploading the code was double-spaced but I believe the extra returns will disappear when uploading the post.
Private Function GetSheet(ByVal SheetName As String) As Worksheet
' 02 Jun 2019
Dim Ws As Worksheet
Set Ws = ActiveSheet ' remember the ActiveSheet
Application.ScreenUpdating = False
On Error Resume Next
Set GetSheet = Worksheets(SheetName) ' error if sheet doesn't exist
If Err Then
' create the sheet
Set GetSheet = Worksheets.Add(After:=Worksheets(Worksheets.Count))
ActiveSheet.Name = SheetName
Ws.Activate ' re-activate the original ActiveSheet
End If
Application.ScreenUpdating = True
End Function
Below is a third version of the same code (I didn't refresh the clipboard between making copies of it here). This time the code was pasted first, with the same result as in the first version above, then selected and the Code tag button pressed to insert the tags around the selection. Up until the moment of posting this behaved in the same manner as the previous example. I expect the double spacing to disappear upon uploading.
Private Function GetSheet(ByVal SheetName As String) As Worksheet
' 02 Jun 2019
Dim Ws As Worksheet
Set Ws = ActiveSheet ' remember the ActiveSheet
Application.ScreenUpdating = False
On Error Resume Next
Set GetSheet = Worksheets(SheetName) ' error if sheet doesn't exist
If Err Then
' create the sheet
Set GetSheet = Worksheets.Add(After:=Worksheets(Worksheets.Count))
ActiveSheet.Name = SheetName
Ws.Activate ' re-activate the original ActiveSheet
End If
Application.ScreenUpdating = True
End Function
This file was created using Excel 2010 and Windows 8.1. I get the same result when using Excel 2013 on a Windows 8.1 (either English or Chinese versions).