Hello guys,
I'm testing a Spreedsheet - CAPCOST, from the book Analysis, Synthesis, and Design of Chemical Processes, but it's not working, always when I try to use "add an equipment" a Run-time error 1004 show up in an yellow arrow in line of this command :
Code macro complete:
Well, I'm a newbee in VBA macros on excel...
Thanks a lot in advance!
I'm testing a Spreedsheet - CAPCOST, from the book Analysis, Synthesis, and Design of Chemical Processes, but it's not working, always when I try to use "add an equipment" a Run-time error 1004 show up in an yellow arrow in line of this command :
Code:
ActiveCell.Offset(iSelection, 7).Value = "=ROUND(" & _
(centrifugeForm.tbBaseCost / Range("CEPCI")) & "*CEPCI, " & iTemp & ")"
Code macro complete:
Code:
'*************************************************************************************
' The module below calculates cost for centrifuges according to the correlations *
' given in "Analysis, Synthesis, and Design of Chemical Processes." *
'*************************************************************************************
Sub calculateCentrifugeCosts()
lCp = 10 ^ (sK1 + sK2 * (Log(sLength) / Log(10)) + sK3 * _
((Log(sLength) / Log(10)) ^ 2)) * (iSpares + 1) / 397 * Range("CEPCI")
If sHolder <> -99 Then
sLength = sHolder
End If
lCBM = lCp * sFBM
centrifugeForm.tbBaseCost.Value = lCp
centrifugeForm.tbBaseCost = Format(centrifugeForm.tbBaseCost, ["$\ #,###,###,###"])
centrifugeForm.tbModuleCost.Value = lCBM
centrifugeForm.tbModuleCost = Format(centrifugeForm.tbModuleCost, ["$\ #,###,###,###"])
End Sub
Sub insertRowsCentrifuge()
bQuestion = False
iSelection = 0
Range("userAddedCentrifuges").Select
Do While bQuestion = False
iSelection = iSelection + 1
If IsEmpty(ActiveCell.Offset(iSelection, 0)) Then
bQuestion = True
End If
Loop
ActiveCell.Offset((iSelection + 1), 0).Rows("1:1").EntireRow.insert Shift:=xlDown
End Sub
Sub insertCentrifuge()
' Centrifuge naming procedure
Range("userAddedCentrifuges").Offset(iSelection, 0).Value _
= "=""Ct-"" & unitNumber + " & Val(iSelection)
Range("userAddedCentrifuges").Offset(iSelection, 1).Value = strCentrifugeType
Range("userAddedCentrifuges").Offset(iSelection, 3).Value = iSpares
iTemp = roundAmount(sLength * Range("preferenceLength"))
Range("userAddedCentrifuges").Offset(iSelection, 2).Value = "=ROUND(" & _
sLength & "*preferenceLength, " & iTemp & ")"
iTemp = roundAmount(centrifugeForm.tbBaseCost)
Range("userAddedCentrifuges").Select
[COLOR=#daa520] [B] ActiveCell.Offset(iSelection, 7).Value = "=ROUND(" & _
(centrifugeForm.tbBaseCost / Range("CEPCI")) & "*CEPCI, " & iTemp & ")"[/B][/COLOR]
ActiveCell.Offset(iSelection, 7).Style = "Currency"
ActiveCell.Offset(iSelection, 7).NumberFormat = _
"_($* #,##0_);_($* (#,##0);_($* ""-""??_);_(@_)"
iTemp = roundAmount(centrifugeForm.tbModuleCost)
ActiveCell.Offset(iSelection, 8).Value = "=ROUND(" & _
(centrifugeForm.tbModuleCost / Range("CEPCI")) & "*CEPCI, " & iTemp & ")"
ActiveCell.Offset(iSelection, 8).Style = "Currency"
ActiveCell.Offset(iSelection, 8).NumberFormat = _
"_($* #,##0_);_($* (#,##0);_($* ""-""??_);_(@_)"
End Sub
Thanks a lot in advance!