No problem.
In the vba editor, add a user form:
Insert > UserForm
You will be presented with a window containing a blank userform, and a floating "Toolbox" window (if you don't see this, open it from the View menu)
Add a label to the userform that occupies the majority of the blank space by clicking the label icon (a capital A) on the toolbox menu and then clicking and dragging on the userform. In the top left corner you should see "Label1"
In the project explorer frame, select UserForm1 and then click
View > Code
In the object dropdown (Probably showing "(General)" select UserForm1
In the procedure dropdown (Probably showing "Click" select Initialize
Edit the Private Sub UserForm_Initialize() as follows:
Private Sub UserForm_Initialize()
UserForm1.Label1.Caption = sResult
End Sub
Change your original code as follows:
Public TheResult As String
Option Compare Text
Sub Find_Old_And_New_Acct_Head()
'To Find the Existing Account Head No and New Account Code Using the Existing Account Head nomenclature
Dim ExistAccHead As String
Dim Cell As Range
Dim wkb As Workbook
Set ActWks = ActiveSheet
Application.ScreenUpdating = False
Application.FindFormat.Clear 'yes
Application.ReplaceFormat.Clear 'yes
ExistAccHead = InputBox("Enter the Account Head Nomenclature")
If ExistAccHead = "" Then Exit Sub
Set wkb = Workbooks.Open("F:\Exist_Final_Acc_Map.xls")
wkb.Activate
With Worksheets("Exist Vs. New")
Sheets("Exist Vs. New").Activate
For Each Cell In Range("C:C") 'Existing Account Head Column
'For Each Cell In Range("C1", Range("C1").End(xlDown)) 'Existing Account Head Column
If Cell Like "*" & ExistAccHead & "*" Then
TheResult = TheResult & Cell & " -- Old Acct Head is -- : " & Cell.Offset(0, -2).Value & " -- New Acct Head is -- : " & Cell.Offset(0, 1).Value & vbCrLf
End If
Next Cell
If TheResult = "" Then TheResult = "Account Head Not Found"
End With
UserForm1.Show 1
wkb.Close
ActWks.Activate
Set ActWks = Nothing
End Sub
Bookmarks