I am attempting to insert data from Excel to a SQL datbase by means of VBA. I am using the following structure in Excel:
I am using the following code:
Private Sub CommandButton1_Click()
Dim i As Integer
Dim p As Integer
Dim product As String
Dim version As String
Dim opt As String
Dim visible As String
Excel.Worksheets("Blad2").Select
i = 3
Do Until IsEmpty(Cells(i, 1))
opt = ActiveSheet.Cells(i, 1)
p = 3
Do Until IsEmpty(Cells(1, p))
product = ActiveSheet.Cells(1, p)
version = ActiveSheet.Cells(2, p)
visible = ActiveSheet.Cells(i, p)
Debug.Print product & version & opt & visible
p = p + 1
Loop
i = i + 1
Loop
End Sub
The result of running the script is as follows:
product#1 version#1 option#1 0
product#1 version#2 option#1 1
option#1
While I want it to result in:
product#1 version#1 option#1 0
product#1 version#2 option#1 1
product#1 version#1 option#2 0
product#1 version#2 option#2 0
Could someone help me out?