Below code searches for the pattern “SESSION DESCRIPTION =”<null>” IS” and if such a pattern is found, asks for Input from the user and replaces the NULL with user's input (Example: SESSION DESCRIPTION =”This input was given by user”).
This code searches the source sheet in its entirety and corrects all NULL description.
Only problem that I face here is, whenever the code reaches the last matching pattern, it stops with a message ”Code execution has been interrupted”.
Please let me know, how I can avoid this error or any work around is required for it..
</null>
This code searches the source sheet in its entirety and corrects all NULL description.
Only problem that I face here is, whenever the code reaches the last matching pattern, it stops with a message ”Code execution has been interrupted”.
Code:
Sub Missing_Description()
'
'
'
Dim ws As Worksheet
Dim Get_Sess_Nm1 As Integer
Dim Get_Sess_Nm2 As Integer
Dim Get_blnk_desc1 As Integer
Set ws = Sheet1
With ws.UsedRange
Set range1 = .Find(What:="SESSION DESCRIPTION ="""" IS", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)
If Not range1 Is Nothing Then
firstAddress = range1.Address
Do
range1.Activate
Get_Sess_Nm1 = InStr(1, range1.Value, " NAME =")
Get_Sess_Nm2 = InStr(1, range1.Value, " REUSABLE")
Session_Name = Replace(Trim(Mid(range1.Value, Get_Sess_Nm1 + 8, Get_Sess_Nm2 - (Get_Sess_Nm1 + 8))), Chr(34), "")
Get_Session_Desc = InputBox("Description not present for session:" & Session_Name, "Please provide session description")
Get_blnk_desc1 = InStr(1, range1.Value, "SESSION DESCRIPTION =" & Chr(34))
Get_blnk_desc2 = InStr(Get_blnk_desc1, range1.Value, Chr(34) & " ISVALID")
Session_Desc = Mid(range1.Value, 1, Get_blnk_desc1 - 1) & Mid(range1.Value, Get_blnk_desc1, 22) & Get_Session_Desc & Mid(range1.Value, Get_blnk_desc2)
range1.Value = Session_Desc
Set range1 = .FindNext(range1)
Loop While Not range1 Is Nothing And range1.Address <> firstAddress
End If
End With
End Sub
Please let me know, how I can avoid this error or any work around is required for it..