# Thread: why overlow... (2000 sr 1)

1. ## why overlow... (2000 sr 1)

During the import txt file i have: stak ovverflow
Why? i am sure the line are 36090 and not 32765

'SITUAZIONE FIRME E POTERI IN ACCORDI
Sub L0747()

Dim riga As String
Dim cont As Integer

cont = 3
FASE = 0
'sott_int = 0

Dim Vfile
Vfile = Application.GetOpenFilename

Open Vfile For Input As #1

While Not EOF(1)
Line Input #1, riga

If Len(Trim(riga)) > 0 Then

If InStr(Mid(riga, 10, 10), "SPORTELLO:") > 0 Then
var_DIP = Mid(riga, 21, 4)
var_CC = Mid(riga, 35, 6)
var_TIPOPROD = Mid(riga, 65, 4)
var_DESCR = Mid(riga, 79, 30)
var_DATTIV = Mid(riga, 122, 10)
FASE = 1
End If

If InStr(Mid(riga, 15, 20), "STATO DELLA PROPOSTA") > 0 Then
var_STATO = Mid(riga, 66, 15)
FASE = 2
End If

If InStr(Mid(riga, 16, 1), "/") > 0 And InStr(Mid(riga, 30, 1), "/") > 0 Then
var_COPE = Mid(riga, 22, 8)
var_NDG = Mid(riga, 31, 9)
var_NOME = Mid(riga, 54, 33)
var_CODRUOLO = Mid(riga, 98, 2)
var_DESCR2 = Mid(riga, 110, 20)
FASE = 3
End If

If FASE = 3 Then
Foglio1.Range("A" & Trim(Str(cont))).Value = var_DIP
Foglio1.Range("B" & Trim(Str(cont))).Value = var_CC
Foglio1.Range("C" & Trim(Str(cont))).Value = var_TIPOPROD
Foglio1.Range("D" & Trim(Str(cont))).Value = var_DESCR
Foglio1.Range("E" & Trim(Str(cont))).Value = var_DATTIV
Foglio1.Range("F" & Trim(Str(cont))).Value = var_STATO
Foglio1.Range("G" & Trim(Str(cont))).Value = var_COPE
Foglio1.Range("H" & Trim(Str(cont))).Value = var_NDG
Foglio1.Range("I" & Trim(Str(cont))).Value = var_NOME
Foglio1.Range("J" & Trim(Str(cont))).Value = var_CODRUOLO
Foglio1.Range("K" & Trim(Str(cont))).Value = var_DESCR2
'Foglio1.Range("g" & Trim(Str(cont))).Value = var_COPE
'Foglio1.Range("g" & Trim(Str(cont))).Value = var_COPE
'Foglio1.Range("h" & Trim(Str(cont))).Value = LTrim(Str(var_importo))
'Foglio1.Range("G" & Trim(Str(cont))).Value = "'" & var_importo
'Foglio1.Range("C" & Trim(Str(cont))).Value = "'" & var_importo

FASE = 0
cont = cont + 1

End If

End If
Wend
Close #1
MsgBox ("MACRO TERMINATA!")
End Sub

2. ## Re: why overlow... (2000 sr 1)

Change

Dim cont As Integer

to

Dim cont As Long

The Integer type has a range from -32768 to +32767, while an Excel worksheet has 65536 rows.

3. ## Re: why overlow... (2000 sr 1)

Good now work!
Note: have you see my last post on "very strong condition...."
Tell me if you like the idea.;-)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•