![]() |
#1
|
|||
|
|||
![]()
Hi
I have the following macro:- Sub CopyRows() ' copy all rows of data in worksheet 'temp' to the appropriate worksheets Dim iLooper As Long, NextRow As Long, ws As Worksheet, strSheet As String With Worksheets("temp") For iLooper = 1 To .Cells(Rows.Count, 1).End(xlUp).Row If UCase(Trim(.Cells(iLooper, "B").Value)) Like "ENROLLMENT*" Then strSheet = "ENROLLMENT" ElseIf UCase(Trim(.Cells(iLooper, "B").Value)) Like "WEEK*" Then strSheet = .Cells(iLooper, "a").Text Else strSheet = "" End If If strSheet <> "" Then Set ws = Worksheets(strSheet) NextRow = ws.Columns("B").Find("*", , xlValues, , 1, 2).Row + 1 ws.Rows(NextRow).Insert ws.Cells(NextRow, "A").Resize(, 8).Value = _ .Cells(iLooper, "A").Resize(, 8).Value End If Next End With ' delete all rows of data in worksheet 'temp' Dim r As Long For r = Cells(Rows.Count, 1).End(xlUp).Row To 3 Step -1 If Cells(r, 1) <> "" Then Rows(r).Delete Next r End Sub When I run it I get the following error:- Run-time error '91' : Object variable or With Block variable not set with the red line highlighted Any suggestions on what is going wrong Bob M p.s. this macro was working OK before ????? |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ktest | Office | 1 | 02-12-2016 08:08 PM |
![]() |
moneal62 | Word VBA | 6 | 01-18-2016 07:54 PM |
![]() |
hlina | Excel | 1 | 10-08-2013 09:14 PM |
Error message | White House | Outlook | 1 | 12-07-2010 04:52 AM |
sent mail error message | Carolemc | Outlook | 0 | 09-26-2006 03:21 AM |