export to MSExcel

  • Thread starter Thread starter al
  • Start date Start date
A

al

Greetings,

I have a form with three group boxes and each has nine textboxs. I
was not able to finde a way to export text in those 27 boxes to Excel.
I mean what is the way to loop through excel cells in code, since
each one has to be hard-coded which makes it difficult to do all 27
cells???

MTIA,
Grawsha


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim xlApp As Excel.Application
xlApp = New Excel.Application
Dim xlBook As Excel.Workbooks

With xlApp
.Visible = True
.Workbooks.Add()
'This is difficult. since each cell has to be hard-coded here instead
of looping
.Range("A1").Value = textbox1.text
End With
End Sub
 
yust a thought (and pseudo code)

dim i,j as integer
dim s as string
Dim xlApp As Excel.Application
xlApp = New Excel.Application
Dim xlBook As Excel.Workbooks
i = asc(A)
for each groupb in form.controls
for each txt in groupb.controls
j +=1
s = chr(i) & j
With xlApp
.Visible = True
.Workbooks.Add()
.Range(s).Value = txt.text
End With

next
i += 1
next

hope it helps eric
 
Back
Top