View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
davegb davegb is offline
external usenet poster
 
Posts: 573
Default Object doesn't support this property or method

Strange. I copied your latest one and pasted it into my code just below
the existing one. They match perfectly (I had removed the Google
hyphens before). Now I'm getting "Error 1004: Application defined or
object defined error", both when I run the whole program and when I run
it in the Immediate Window. The entire program is:

Sub RecurExtract()
'Password used
Dim CtyCode As String
Dim WkSht As Object
Dim PWORD As String
Dim ChPrior, PostServ, FirstDt, LastDt As String

PWORD = "dave"

CtyCode = ActiveCell
Set WkSht = ActiveWorkbook.Sheets("Recurrence Records")
WkSht.Unprotect Password:=PWORD
Sheets("Recurrence Records").Range("S2") = CtyCode
Range("A195:A199").Select
Selection.Copy

WkSht.Protect Password:=PWORD

Sheets("County Records").Select
Worksheets("County Records").UsedRange.Clear

Range("a1:i1").Select
Selection.Merge
ActiveCell.FormulaR1C1 = _
"WARNING: This data will be erased the next time County
Records are extracted. "
With ActiveCell.Characters(Start:=1, Length:=78).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 7
End With

Range("A2:I2").Select
Selection.Merge
ActiveCell.FormulaR1C1 = _
"If you wish to save the data, copy and paste it to another
spreadsheet or print it out before doing another data extraction."
With ActiveCell.Characters(Start:=1, Length:=124).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.ColorIndex = 7
End With
Range("A2:I2").Select
With Selection
.WrapText = True
.MergeCells = True
End With

Rows("2:2").RowHeight = 30

Application.CutCopyMode = False
Sheets("Recurrence Records").Range("A1:M192").AdvancedFilter
Action:= _
xlFilterCopy, CriteriaRange:=Sheets("Recurrence
Records").Range("S1:S2"), _
CopyToRange:=Range("A5"), Unique:=False
Range("A4:E4").Select
Selection.Merge
Range("a4") = CtyCode & " County Recurrence Records"
With ActiveCell.Characters(Start:=1, Length:=78).Font
.Name = "Arial"
.FontStyle = "Bold"
End With
Columns("A:M").EntireColumn.AutoFit

Range("A5:M5").Select
With Selection
.VerticalAlignment = xlBottom
.WrapText = True

End With
Rows("5:5").RowHeight = 24.75


Worksheets("County Records").Range("a5").End(xlDown).Offset(2,
0).PasteSpecial xlPasteAll

End Sub

How can it do one thing in your Immediate Window and something else in
mine?
Thanks for all the help.