JPARKHURST
Board Regular
- Joined
- Oct 25, 2016
- Messages
- 151
I would like to have a function which takes in a variable (say, worksheet), and determines if that worksheet is populated.
This is what I had, and I thought it was working fine, but i was wrong.
My purpose is to have a 'checker' which lets me know if I have already created an object, and if so if it is populated? I am trying to be able to create worksheet objects which I can use across my project (all within one workbook). I would much rather do this than have 10 objects with different names because I want to access a sheet in 3 different modules.
"Object Variable or with block not set"
This is what I had, and I thought it was working fine, but i was wrong.
My purpose is to have a 'checker' which lets me know if I have already created an object, and if so if it is populated? I am trying to be able to create worksheet objects which I can use across my project (all within one workbook). I would much rather do this than have 10 objects with different names because I want to access a sheet in 3 different modules.
"Object Variable or with block not set"
Code:
Public Sub CnSwS(wb101 As Workbook, ws101 As Worksheet, sws101 As String)
'Check to see if Worksheet variables have been established, and if not, establish them!
If ws101 Is Nothing Then
Set ws101 = wb101.Sheets(sws101)
End If
End Sub