DblDocWhitaker
New Member
- Joined
- Mar 31, 2020
- Messages
- 10
- Office Version
- 2016
- Platform
- Windows
Good morning. I have been building various userforms for auto-filling standard letters that we use in the office. Rather than typing the same series of commands in each userform (such as for identifying contact information for the designated person), I was hoping to build a macro and then call that macro in the userforms that need it.
My userform has a combobox that lists the persons in the office. The userform gathers that information as this:
Dim Sign As String
Sign = Me.cbSign.Value
I then created a class module (shown below my text). I call this module from my user form with:
Call ContactInfo
However, the information is not loading. For example, I tried troubleshooting by placing "msgbox Facsimile" in various places to see if I was getting the information loaded, and it gives me a blank message box. What am I missing?
******************************************
'For populating signature blocks and such
Public Function ContactInfo()
Dim SignLast As String
SignLast = Sign
Dim SignFirst As String
Dim AreaCode As String
Dim SignPhone As String
Dim SignEmail As String
Dim SignJob As String
Dim SignAdd1 As String
Dim SignAdd2 As String
Dim SignCity As String
Dim SignState As String
Dim SignZipCode As String
Dim Facsimile As String
With Worksheets("Attorneys").Range("LastName")
Set c = .Find(Sign, LookAt:=xlWhole)
If Not c Is Nothing Then
SignFirst = c.Offset(0, -1).Value
AreaCode = c.Offset(0, 2).Value
SignPhone = c.Offset(0, 3).Value
SignEmail = c.Offset(0, 4).Value
SignJob = c.Offset(0, 6).Value
SignAdd1 = c.Offset(0, 7).Value
SignAdd2 = c.Offset(0, 8).Value
SignCity = c.Offset(0, 9).Value
SignState = c.Offset(0, 10).Value
SignZipCode = c.Offset(0, 11).Value
Facsimile = c.Offset(0, 12).Value
End If
End With
End Function
My userform has a combobox that lists the persons in the office. The userform gathers that information as this:
Dim Sign As String
Sign = Me.cbSign.Value
I then created a class module (shown below my text). I call this module from my user form with:
Call ContactInfo
However, the information is not loading. For example, I tried troubleshooting by placing "msgbox Facsimile" in various places to see if I was getting the information loaded, and it gives me a blank message box. What am I missing?
******************************************
'For populating signature blocks and such
Public Function ContactInfo()
Dim SignLast As String
SignLast = Sign
Dim SignFirst As String
Dim AreaCode As String
Dim SignPhone As String
Dim SignEmail As String
Dim SignJob As String
Dim SignAdd1 As String
Dim SignAdd2 As String
Dim SignCity As String
Dim SignState As String
Dim SignZipCode As String
Dim Facsimile As String
With Worksheets("Attorneys").Range("LastName")
Set c = .Find(Sign, LookAt:=xlWhole)
If Not c Is Nothing Then
SignFirst = c.Offset(0, -1).Value
AreaCode = c.Offset(0, 2).Value
SignPhone = c.Offset(0, 3).Value
SignEmail = c.Offset(0, 4).Value
SignJob = c.Offset(0, 6).Value
SignAdd1 = c.Offset(0, 7).Value
SignAdd2 = c.Offset(0, 8).Value
SignCity = c.Offset(0, 9).Value
SignState = c.Offset(0, 10).Value
SignZipCode = c.Offset(0, 11).Value
Facsimile = c.Offset(0, 12).Value
End If
End With
End Function