Convert value in the cell into integer

Closed
arilla Posts 1 Registration date Saturday August 2, 2008 Status Member Last seen August 3, 2008 - Aug 3, 2008 at 10:06 AM
 no - Jul 31, 2012 at 12:04 AM
Hello,

I am working on creating a macro. I want to go through the sheet and take the quantity that enter in the cell and copy and insert the row as many times as the value that enter in the cell. How do I convert the number in the cell into integer so I could use it as a counter. For example, cell(1,1) has the number 4 in it, so I want to copy the entire row and paste it 4 times. My code doesn't work because when I used Cell(1,i).value it doesn't convert it into integer. Would you please tell me how do I convert the value inthe cell into integer? Thank you very much, any help would be appreciated.


Sub findQty()

Dim LastLine As Integer, i, i1 As Integer
Dim qty As Integer


Sheets("List").Activate
LastLine = Cells(Columns("A").Rows.Count, 1).End(xlUp).Row
For I = 1To LastLine

qty = (Cells(1, i).Value)
If (Cells(1, i).Value) > 1 Then

For i1 = 1 To qty


Rows("7:7").Select
Selection.Copy
Selection.Insert Shift:=xlDown
Cells(1, i).FormulaR1C1 = "1"
Next i1
End if
Next i
Related:

1 response

Ivan-hoe Posts 433 Registration date Saturday February 16, 2008 Status Member Last seen October 17, 2008 110
Aug 5, 2008 at 12:26 PM
Hello arilla,
use CInt to convert a numeric value into integer
qty = CInt(Cells(1, i).Value)

Ivan
12
dear sir I am sandeep
Phone number removed for security
0