cjdhx9
07-22-2008, 08:51 AM
Hey all,
I was hoping to get some help with a project. I'm doing an erosion study on a piece of equipment that I work with. I have a wall thickness and an erosion rate. I was hoping made a module that would simply run the equation "thickness - rate * x = 0", where x is time (in minutes) and would increase by increments of 1 until the statement was met. Then return the value x into another cell. Pretty much telling me how many minutes more it would take before the thickness of the part became 0. This is what I've got so far, but I get an error stating "object required" on "x =" in the fourth line.
Sub TimeRemaining()
Dim x As Integer, w As Integer
Dim Thickness As Long, Rate As Long
Set x = 1
Set w = 2
Set Thickness = Range(AFw).Value
Set Rate = Range(ANw).Value
Do Until Thickness - Rate * x = 0
Set x = x + 1
Loop
Range(APw).Activate
Set ActiveCell = x
Set w = w + 1
End Sub
In my module x is the Time I mentioned above, w is the row number. Thickness is the wall thickness of the part, rate is the rate of erosion. Then I set x = 1 and it gives me the error "Object Required". Besides that I'm not sure if the "Set Thickness = Range(AFw).Value" will actually work. The column was AF and I was hoping to be able to just move down one row as I increased the variable w later on. But I'm not sure if that would actually work. I appreciate any help.
I was hoping to get some help with a project. I'm doing an erosion study on a piece of equipment that I work with. I have a wall thickness and an erosion rate. I was hoping made a module that would simply run the equation "thickness - rate * x = 0", where x is time (in minutes) and would increase by increments of 1 until the statement was met. Then return the value x into another cell. Pretty much telling me how many minutes more it would take before the thickness of the part became 0. This is what I've got so far, but I get an error stating "object required" on "x =" in the fourth line.
Sub TimeRemaining()
Dim x As Integer, w As Integer
Dim Thickness As Long, Rate As Long
Set x = 1
Set w = 2
Set Thickness = Range(AFw).Value
Set Rate = Range(ANw).Value
Do Until Thickness - Rate * x = 0
Set x = x + 1
Loop
Range(APw).Activate
Set ActiveCell = x
Set w = w + 1
End Sub
In my module x is the Time I mentioned above, w is the row number. Thickness is the wall thickness of the part, rate is the rate of erosion. Then I set x = 1 and it gives me the error "Object Required". Besides that I'm not sure if the "Set Thickness = Range(AFw).Value" will actually work. The column was AF and I was hoping to be able to just move down one row as I increased the variable w later on. But I'm not sure if that would actually work. I appreciate any help.