Having a bit of an issue with some code here. I want to do three things. I want to skip the line in a range if it contains "LINE:", I want to remove any trailing "-" in the string, and I want to turn any positive values into negative values. Below is my code, but I'm having trouble with it. I'm getting a "Type mismatch" error on the below line.
ElseIf cellh.Value > 0 Then cellh.Value = cellh.Value * 1
I'm thinking it's because it's trying to evaluate a range instead of integer, but I need to be able to reference the range to keep the for each going. Any help would be appreciated. Code below. Thanks!
Sub Test()
Dim rngh As Range, cellh As Range
Dim myString As String
Set rngh = Range("E1:E24")
For Each cellh In rngh
If Not InStr(cellh, "LINE:") > 0 Then
ElseIf InStr(cellh, "-") > 0 Then
myString = cellh.Text
myString = Left(myString, Len(myString) - 1)
cellh.Value = myString
ElseIf cellh.Value > 0 Then cellh.Value = cellh.Value * -1
End If
Next cellh
End Sub
Aucun commentaire:
Enregistrer un commentaire