I
inspired
At the "Find" line, I get a runtime error 1004 Application-defined
or object-defined error. I tried Googling this, but I could not find
a solution for this particular occurrence. My code may be found
below.
Can anyone help? Thanks, Alan
Sub ExtractMessages()
Dim row As Long, LastRow As Long, temp As String, MsgRow As Long,
LastMsgRow As Long, FindMsgName As String
Dim pos As Integer, message As String, purpose As String,
initiation As String, trigger As String
Dim msgstriggered As String, MessageWS As Object, MessageListWS As
Object, rng As Range
Set MessageWS = Worksheets("Messages")
Set MessageListWS = Worksheets("MessageList")
LastRow = MessageWS.UsedRange.Rows.Count
LastMsgRow = MessageListWS.UsedRange.Rows.Count
' Turn off screen updates
Application.ScreenUpdating = False
' Look for each message
For MsgRow = 1 To LastMsgRow
FindMsgName = MessageListWS.Cells(MsgRow, 1).Value
FindMsgName = Trim(FindMsgName)
If Len(FindMsgName) > 0 Then
' Find matching message name
With MessageWS.Cells
Set rng = .Find(What:=FindMsgName, After:=.Cells(1,
1), LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
End With
If Not (rng Is Nothing) Then rng.Activate
End If
Next MsgRow
Application.ScreenUpdating = True
End Sub
or object-defined error. I tried Googling this, but I could not find
a solution for this particular occurrence. My code may be found
below.
Can anyone help? Thanks, Alan
Sub ExtractMessages()
Dim row As Long, LastRow As Long, temp As String, MsgRow As Long,
LastMsgRow As Long, FindMsgName As String
Dim pos As Integer, message As String, purpose As String,
initiation As String, trigger As String
Dim msgstriggered As String, MessageWS As Object, MessageListWS As
Object, rng As Range
Set MessageWS = Worksheets("Messages")
Set MessageListWS = Worksheets("MessageList")
LastRow = MessageWS.UsedRange.Rows.Count
LastMsgRow = MessageListWS.UsedRange.Rows.Count
' Turn off screen updates
Application.ScreenUpdating = False
' Look for each message
For MsgRow = 1 To LastMsgRow
FindMsgName = MessageListWS.Cells(MsgRow, 1).Value
FindMsgName = Trim(FindMsgName)
If Len(FindMsgName) > 0 Then
' Find matching message name
With MessageWS.Cells
Set rng = .Find(What:=FindMsgName, After:=.Cells(1,
1), LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
End With
If Not (rng Is Nothing) Then rng.Activate
End If
Next MsgRow
Application.ScreenUpdating = True
End Sub