aadetoro
Jul 26th, 1999, 02:32 AM
I have a little trouble with this program. The coding is correct, but I am having problems getting it to work on certain files.
What happens is this, when i start a new worksheet and type in my info manually, the macro works just fine. But when i open up a saved worksheet that already has info in it, the program does not work.
I am thinking there is a problem somewhere with the setup of the worksheet. But how do i access this setup so i can get my programming running on any worksheet file.
I greatly appreaciate you guys help.
Abi
here is my main function...
___________________________
Dim c As Object
Dim maxrows As Integer
Sub Main()
'Const limit As String = "1999"
Dim myval As Integer
'Set myCell = Worksheets("Sheet1").Range("a1:c10")
Dim x, y As Integer
x = 1
y = 1
'replaces 1999 with 99
Cells.Select
Selection.Replace What:="1999", Replacement:="99", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
'sort cells in hdate order
Call Hdate
Call CurrentWeek(myval)
MsgBox "The value is " & myval
Call Numrows(maxrows)
MsgBox "The # of rows is " & maxrows
'checks each row of jobs and deletes those with an hdate earlier than current.
Do
Set c = Worksheets("Sheet1").Cells(x, y)
If c.Value < myval Then
Call DeleteRow(x, y)
End If
x = x + 1
y = y + 1
Loop Until x = maxrows + 1
'sorts in state and then in OM order.
r
x = 1
y = 10
Do
Set c = Worksheets("Sheet1").Cells(x, y)
If (c.Text = "NC") Then
Call DeleteRow(x, y)
End If
x = x + 1
Loop Until x = maxrows + 1
MsgBox "All done!"
End Sub
What happens is this, when i start a new worksheet and type in my info manually, the macro works just fine. But when i open up a saved worksheet that already has info in it, the program does not work.
I am thinking there is a problem somewhere with the setup of the worksheet. But how do i access this setup so i can get my programming running on any worksheet file.
I greatly appreaciate you guys help.
Abi
here is my main function...
___________________________
Dim c As Object
Dim maxrows As Integer
Sub Main()
'Const limit As String = "1999"
Dim myval As Integer
'Set myCell = Worksheets("Sheet1").Range("a1:c10")
Dim x, y As Integer
x = 1
y = 1
'replaces 1999 with 99
Cells.Select
Selection.Replace What:="1999", Replacement:="99", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
'sort cells in hdate order
Call Hdate
Call CurrentWeek(myval)
MsgBox "The value is " & myval
Call Numrows(maxrows)
MsgBox "The # of rows is " & maxrows
'checks each row of jobs and deletes those with an hdate earlier than current.
Do
Set c = Worksheets("Sheet1").Cells(x, y)
If c.Value < myval Then
Call DeleteRow(x, y)
End If
x = x + 1
y = y + 1
Loop Until x = maxrows + 1
'sorts in state and then in OM order.
r
x = 1
y = 10
Do
Set c = Worksheets("Sheet1").Cells(x, y)
If (c.Text = "NC") Then
Call DeleteRow(x, y)
End If
x = x + 1
Loop Until x = maxrows + 1
MsgBox "All done!"
End Sub