IREALLYambatman
Board Regular
- Joined
- Aug 31, 2016
- Messages
- 63
Hey guys my code below works only partially.. basically whenever it wants.
For the first part of the code where it looks for dilutions (ie x5 x10 x20 x2.5) it doesn't recognize decimals.. Can the string value be changes to recognize that?
For the C1 part of the code: Seems to never c1 if one of the cells is blank, which it should (which should be a zero so C1 should be written). There are other problems with it too.. I just can't honestly remember what the issues are but rarely does it actually flag all the columns that it should.
For the first part of the code where it looks for dilutions (ie x5 x10 x20 x2.5) it doesn't recognize decimals.. Can the string value be changes to recognize that?
For the C1 part of the code: Seems to never c1 if one of the cells is blank, which it should (which should be a zero so C1 should be written). There are other problems with it too.. I just can't honestly remember what the issues are but rarely does it actually flag all the columns that it should.
Code:
Sub AnionsWater()
Sub AnionsWater()
ActiveWorkbook.Worksheets("Edit Here").Cells.EntireColumn.AutoFit
'Find the last used column in a Row: row 1 in this example
With ActiveSheet
LastCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
End With
Range(Range("c10"), Cells(10, LastCol)).Value = "300.1_W"
Range(Range("c14"), Cells(14, LastCol)).Value = "Water"
Range(Range("c13"), Cells(13, LastCol)).Value = "1"
Dim cell As Range
Dim loc As Integer
Dim str As String
For Each cell In Range("C4", "ZZ4")
loc = InStr(1, cell.Value, " x")
If loc > 0 Then
str = Mid(cell.Value, loc + 2)
loc = InStr(1, str, " ")
If loc > 0 Then
str = Left(str, loc - 1)
End If
If IsNumeric(str) Then cell.Offset(9, 0).Value = CInt(str)
End If
loc2 = InStr(1, cell.Value, " X")
If loc2 > 0 Then
str = Mid(cell.Value, loc2 + 2)
loc2 = InStr(1, str, " ")
If loc2 > 0 Then
str = Left(str, loc2 - 1)
End If
If IsNumeric(str) Then cell.Offset(9, 0).Value = CInt(str)
End If
Next
Dim c As Range
For Each c In Range(Range("c13"), Cells(13, LastCol))
If c.Value * c.Offset(26).Value <= 90 Or c.Value * c.Offset(18).Value >= 115 Then c.Offset(3).Value = "c1"
Next c
End Sub
End Sub