Hi Guys,
I need your help,
Please note I am trying to use the value from a Textbox (Have a formula an extract a cell value (number with format as percentage) to convert to integer or number in order to proceed with a condition to determine if the value is X1 < 0 , X1 > 0 or X1 = 0 (This part already done but unfortunately I have to use zero as text ("0") , I have the issue that X1 = "0,00%" does not work so I think that maybe try to convert to integer can be easy and faster avoid changing the whole code.
Code below is what I am looking but I have never converted a string to Number or Integer, I tried many codes from other people but cause me an error.
Appreciate a lot if you can provide a small code for this.
I need your help,
Please note I am trying to use the value from a Textbox (Have a formula an extract a cell value (number with format as percentage) to convert to integer or number in order to proceed with a condition to determine if the value is X1 < 0 , X1 > 0 or X1 = 0 (This part already done but unfortunately I have to use zero as text ("0") , I have the issue that X1 = "0,00%" does not work so I think that maybe try to convert to integer can be easy and faster avoid changing the whole code.
Code below is what I am looking but I have never converted a string to Number or Integer, I tried many codes from other people but cause me an error.
VBA Code:
Dim Sht, Sht2 As Worksheet
Dim ID, X1 As String
Dim i, lastRow, Y1 As Integer
Set Sht = ThisWorkbook.Sheets("OOO")
Set Sht2 = ThisWorkbook.Sheets("AAA")
Range("B2").Select
lastRow = Sht2.Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To lastRow
ID = ActiveCell.Value 'There is a table with the name of the shape with a loop so activecell is going to be a name of a shape
X1 = Sht.Shapes(ID).TextFrame.Characters.Text 'The value extracted is a cell value, example can be "-5.67%" (Minor than 0) , "0.00%" (equal to Zero) and "7,90%" (Major to zero).
Y1 = CInt(X1) 'I was trying to do something like this but does not work :D so string can convert to integer or number
'in order to determine the statements below and based on those be able to apply different formats based on Y1 Value.
IF Y1< 0 Then
..................
ELSEIF Y1> 0 Then
..................
ELSEIF Y1= 0 Then
..................
END IF
ActiveCell.Offset(1, 0). Activate
Next i
End Sub
Appreciate a lot if you can provide a small code for this.
Last edited: