Convert value in the cell into integer [Closed]

Report
Posts
1
Registration date
Saturday August 2, 2008
Status
Member
Last seen
August 3, 2008
-
 no -
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

1 reply

Posts
436
Registration date
Saturday February 16, 2008
Status
Member
Last seen
October 17, 2008
109
Hello arilla,
use CInt to convert a numeric value into integer
qty = CInt(Cells(1, i).Value)

Ivan
12
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 4126 users have said thank you to us this month

dear sir I am sandeep
Phone number removed for security