View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Code Error Message Excel 2000 - 2003

Sub DateTesterBaselineIncrease()
Dim Baseline As Date
Dim Rng As Range
Baseline = "1/1/2005"
Set Rng = ThisWorkbook.Worksheets("Settings_North").Range("B 2")
ThisWorkbook.Activate
rng.Parent.Select
Rng.Select

Do Until Selection = ""
SelCol = Selection - Baseline
With Selection
.Value = DateSerial(year(.Value) + 1, Month(.Value), Day(.Value))
End With
Selection.Offset(1, 0).Select
loop

End Sub

What is the point of the SelCol calculation. You don't use it.



--
Regards,
Tom Ogilvy


"jfcby" wrote in message
ups.com...
Hello,

Can this code be changed to reference 2 worksheets?

Sub DateTesterBaselineIncrease()
Dim Baseline As Date
Dim Rng As Range
Baseline = "1/1/2005"
Set Rng = ThisWorkbook.Worksheets("Settings_North").Range("B 2")
Rng.Select
Do
Do Until Selection = ""
SelCol = Selection - Baseline
With Selection
.Value = DateSerial(year(.Value) + 1, Month(.Value), Day(.Value))
End With
Selection.Offset(1, 0).Select
Exit Do
Loop
Loop Until Selection = ""
End Sub

I get ths error message:

Run time error '1004'
Select method of range class failed

when debug it highlights this line:

Rng.Select

Thank you for your help,
jfcby