Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
oBook = oExcel.Workbooks.Open("C:\Documents and Settings\Desktop\Excelfyp")
Try
With oExcel
.Visible = False
'Add details
If Gdate = "15 February 2010" Then
.Range("C99").Value = TextBox1.Text
.Range("C100").Value = TextBox2.Text
.Range("C101").Value = TextBox3.Text
.Range("C102").Value = TextBox4.Text
.Range("C103").Value = TextBox5.Text
.Range("C3104").Value = TextBox6.Text
.Range("C105").Value = TextBox7.Text
.Range("C106").Value = TextBox8.Text
.Range("C107").Value = TextBox9.Text
.Range("C108").Value = TextBox10.Text
.Range("C109").Value = TextBox11.Text
.Range("C111").Value = TextBox12.Text
.Range("C112").Value = TextBox13.Text
.Range("C113").Value = TextBox14.Text
End If
End With
Catch ex As Exception
MsgBox("Error: " & ex.ToString, MsgBoxStyle.Critical, "Error!")
End Try
oBook.Save()
oBook.Close()
End Sub
End Class
This code works and the information goes in. If the date is 16th of feb I want any data that i type in to go into the same cells as above but in COLUMN E instead and if the date is the 17th of feb I want any data that I type in to go onto the same cells as above but in COLUMN G etc.. For every extra date i want it to increment by 2 columns. I have tried adding in:
Dim column As String = "C"
Dim Gdate As Date = "01 January 2010"
Dim todayDate As Date = DateTime.Now
Do
column = Chr(Asc(column) + 2)
Gdate = Gdate.AddDays(1)
Loop Until Gdate = todayDate
But it doesn't work. Any help at all would be greatly appreciated. Thank you.
This post has been edited by AdamSpeight2008: 15 February 2010 - 07:32 AM
Reason for edit:: Added Code Tags

New Topic/Question
Reply




MultiQuote






|