I'm trying to write a macro for a hydro-logic model worth a decent % of my grade, and I keep getting the 1004
error. It's centered on the first line of the first If statement.
This is the code that I'm using:
Sub pheonix()
'
' pheonix Macro
'
' Keyboard Shortcut: Ctrl+u
'
Dim WS As Worksheet
Set WS = Sheets.Add
Sheets.Add.Name = "RESULTS"
Sheets("Case 2").Select
Range("C1:R1").Select
Selection.Copy
Sheets("RESULTS").Select
ActiveSheet.Paste
Dim Row As Integer
Dim Day As Integer
Dim SurfaceInflow As Integer
Dim GroundwaterOutflow As Integer
Dim SurfaceOutflow As Integer
Dim Stage As Integer
Dim Evap As Integer
Dim Precip As Integer
Dim AreaL As Integer
Dim ChangeStorage As Integer
Dim Storage As Integer
Dim InitialStorage As Integer
Dim InitialStage As Integer
Dim InitialArea As Integer
Row = 2
'calulation for initial day
'InitialStage = "4"
'InitialArea = 11 * InitialStage ^ 0.5
'InitialStorage = (22 / 3) * (InitialStage ^ (3 / 2))
Set wksSource = ActiveWorkbook.Sheets("Case 2")
Set wksDest = ActiveWorkbook.Sheets("RESULTS")
For Day = 5 To 734
Sheets("RESULTS").Cells(Row, "A") = Sheets("Case 2").Cells(Row, "C")
For i = 0 To 288
Sheets("Case 2").Select
SurfaceInflow = ((0.2 * Cells(Day, "G")) * ((1 - 0.4) * (557 - Cells(Day, "J")))) + ((0.95 * Cells(Day, "G")) * (0.4 * (557 - Cells(Day, "J"))))
If Cells(Stage, "H") >= 1.348 Then
GroundwaterOutflow = (0.379 * Cells(Stage, "H") - 0.511)
Else: GroundwaterOutflow = 0
End If
If Cells(Stage, "H") > 2.9 Then
SurfaceInflow = (33 * (Cells(Stage, "H") - 2.9) ^ (3 / 2))
Else: SurfaceInflow = 0
End If
Precip = Cells(Precip, "S")
Evap = Cells(Evap, "T")
Area = (11 * Cells(Stage, "H") ^ 0.5)
ChangeStorage = (Area * (Precip - Evap)) - GroundwaterOutflow + SurfaceInflow - SurfaceOutflow
Storage = Storage + ChangeStorage
Next i
Sheets("RESULTS").Cells(Row, "B") = "X"
Row = Row + 1
Next Day
End Sub
Help? I'm not super familiar with any programming, this was a rather unfortunate project sprung on us by the prof.