M
Milind
Hello
Though my code runs well, if I run it the second time, though I have issued
the statement "counter=0", it starts from the last used value. The code is
like this:
counter = 0
For Each c In Worksheets("Sheet1").Range("A2:A100").Cells
valie = c.Value
If c.Value = 22381 Then
wala = c.Offset(0, 5).Value
If wala = "pills" Then
milla = c.Offset(0, 2).Value
Call file_write
End If
End If
Next c
counter = 0
End Sub
Sub file_write()
Set wkbk = Nothing
On Error Resume Next
Set wkbk = Workbooks("sample-2.xls")
On Error GoTo 0
If wkbk Is Nothing Then
Workbooks.Open FileName:="C:\milinda\sample-2.xls"
End If
Range("E" & counter + 1).Value = milla
Selection.NumberFormat = "#,##0.00"
counter = counter + 1
End Sub
How to cope with this ?
Milind
Though my code runs well, if I run it the second time, though I have issued
the statement "counter=0", it starts from the last used value. The code is
like this:
counter = 0
For Each c In Worksheets("Sheet1").Range("A2:A100").Cells
valie = c.Value
If c.Value = 22381 Then
wala = c.Offset(0, 5).Value
If wala = "pills" Then
milla = c.Offset(0, 2).Value
Call file_write
End If
End If
Next c
counter = 0
End Sub
Sub file_write()
Set wkbk = Nothing
On Error Resume Next
Set wkbk = Workbooks("sample-2.xls")
On Error GoTo 0
If wkbk Is Nothing Then
Workbooks.Open FileName:="C:\milinda\sample-2.xls"
End If
Range("E" & counter + 1).Value = milla
Selection.NumberFormat = "#,##0.00"
counter = counter + 1
End Sub
How to cope with this ?
Milind