LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Need error trap

I have this macro which does as intended, except if it does not find a
match (Line beginning with Set frngmatch..............). What I would
like is for the macro to continue looping to next project and finish
adding and renaming sheets. My code is below:

Sub Copy340WIPActiveWorkbook()
Dim WBwip As Workbook
Dim wb2 As Workbook
Dim rng As Range
Dim frngMatch As Range
Dim Cel As Range
Dim SName As String
Const sStr As String = "A2"
Dim frng As Range
Dim iRow As Long
Dim Lrow As Long
Dim Findstr As String

Set wb2 = ActiveWorkbook
Lrow = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = wb2.ActiveSheet.Range("A6:A" & Lrow)

On Error Resume Next
Set WBwip = Workbooks("RF 340-000.xls")
On Error GoTo 0
If WBwip Is Nothing Then
ChDir "S:\FIN\Finance\Capital Projects\WIP Detail"
Workbooks.Open filename:= _
"S:\FIN\Finance\Capital Projects\WIP Detail\RF 340-000.xls"
Set WBwip = Workbooks("RF 340-000.xls")
Else
'already open
End If

iRow = 5

Do Until iRow = Lrow
wb2.Activate
Range("A1").Select

FindProj = Left(ActiveCell.Offset(iRow, 0).Value, 6)

Set frng = Cells.Find(what:=FindProj, LookIn:=xlFormulas,
lookat:=xlPart)
If Not frng Is Nothing Then
WBwip.Sheets("340-000-900 Pivot Table").Activate
'Findstr = frng.Offset(0, 9).Address(1, 1, xlA1)
Else
MsgBox ("Project, not found")
End If
Set frngMatch = Cells.Find(what:=FindProj, LookIn:=xlFormulas,
lookat:=xlPart) 'Errors here if not found
frngMatch.Activate
ActiveCell.Offset(0, 10).Select

Selection.ShowDetail = True

ActiveSheet.Move After:=wb2.Worksheets(wb2.Worksheets.Count)
ActiveWindow.Zoom = 75
ActiveSheet.Name = Left(Range(sStr), 6)

iRow = iRow + 1

Loop

Application.DisplayAlerts = True

End Sub

Thanks, Greg

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error Trap Kirk P. Excel Programming 2 September 8th 05 09:51 PM
Error Trap TEB2 Excel Programming 2 March 15th 05 05:34 PM
error trap Rhonda[_3_] Excel Programming 2 October 22nd 03 07:07 PM


All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"