View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Object Required error on Weekly Summary sheet creation

It appears that you haven't declared your variables consistently. Put Option
Explicit before your sub and then compile the VBA project to figure out the
problems.
--
HTH,
Barb Reinhardt



"davegb" wrote:

I'm removing dupes from a list. The following code gives an "object
required" error on the marked line. The variable is declared as a
range object, is set, and is recognized in the commands immediately
above. So why not in this line?
Sub WklySumWS()

Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String
Dim rStartCell As Range
Dim rTaskList As Range
Dim rTaskStart As Range
Dim rTask As Range
Dim rNextTask As Range
Dim sTask As String
Dim sNextTask As String
Dim lTask As Long
lTask = 1


Set wsWklyLst = ActiveSheet
Set rStartCell = wsWklyLst.Range("B1")


sWklyShtName = wsWklyLst.Name

'Create Weekly Summary Sheet
Sheets.Add.Activate
Set wsWklySum = ActiveSheet
Set rTaskStart = wsWklySum.Range("A1")


ActiveSheet.Name = sWklyShtName & " Summary"
wsWklySum.Move Befo=Sheets("Project Summary")
wsWklyLst.Range(rStartCell, rStartCell.End(xlDown)).Copy
wsWklySum.Range("A1").PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending


Set rTaskList = wsWklySum.Range(rTaskStart, rTaskStart.End(xlDown))

For Each rTask In rTaskList
sTask = rTask.Value
Set rNextTask = rTask.Offset(1, 0)
sNextTask = rNextTask
Do While sNextTask < ""
Do While sTask = sNextTask
rNextTask.EntireRow.Delete <----OBJECT REQUIRED ERROR
Loop
Loop


Next rTask
End Sub

Thanks in advance.