Quasi ci siamo....
mi sai dire se invece di
"For r = 2 To Selection.Rows.Count + 1"
si può, al posto del 2, dargli un valore corrispondente alla prima riga selezionata?
ora il codice sotto scrive correttamente la quantità e la sequenza di righe ma comincia sempre da 2...perché glielo dico io con la riga sopra riportata
Codice:
Sub textfile()
Dim rRange As Range
Dim fs As Object, a As Object, i As Integer, s As String
On Error Resume Next
Application.DisplayAlerts = False
Set rRange = Application.InputBox(Prompt:= _
"Selezionare con il mouse le celle da esportare come testo.", _
Title:="SELEZIONARE LE CELLE", Type:=8)
On Error GoTo 0
Application.DisplayAlerts = True
If rRange Is Nothing Then
Exit Sub
Else
rRange.Select
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\simone\Desktop\" & Range("A1").Value & ".txt", True)
'r = ActiveCell.Row ' set the active row to write '<== se lo attivo non cambia!
For r = 2 To Selection.Rows.Count + 1
s = "" 'clear buffer '<== spostato
c = 1 ' start in column "A" '<== spostato
While Not IsEmpty(Cells(r, c)) 'start at column 1 and do until no more columns of data
s = s & Cells(r, c) & ";" 'write a cell of data and add a ;
c = c + 1 'increment to next column
Wend
a.writeline s 'write line to text file
Next r
End Sub
___________________________________
"...e il mio maestro mi insegnò com'è difficile trovare l'alba dentro l'imbrunire..." (F.Battiato)
S
A