JasonEnsor
Programmer
Hi Guys,
I am currently building an SQL generator that will spit out .Sql files based upon selections made in an excel document. I am using Excel as it is a great storage container for the changing values. In my first prototype i had multiple worksheets setup where my vba would call a particular worksheet to get the relevant data. Eg. I have a Profile Options worksheet, Customer Options...The number of Excel worksheets were becoming a bit excessive, so i have started to redesign the system. This time i thought about using tables as they can be resized and it means multiple tables can be used on one worksheet. this means less worksheets in the workbook.
Previously i was using the following to loop through a worksheet and populate a ListView control.
I am wanting to do this now using a table but seem to be struggling. I have tried the following
However no data is showing up on the ListView control. Ideally i would like the code to loop through and populate all enteries in the table. Once i get that sorted i can replicate the code for my other ListViews.Then move on to resizing the tables as needed.
I can give more information if needed
Many Thanks in advance guys
J.
Regards
J.
I am currently building an SQL generator that will spit out .Sql files based upon selections made in an excel document. I am using Excel as it is a great storage container for the changing values. In my first prototype i had multiple worksheets setup where my vba would call a particular worksheet to get the relevant data. Eg. I have a Profile Options worksheet, Customer Options...The number of Excel worksheets were becoming a bit excessive, so i have started to redesign the system. This time i thought about using tables as they can be resized and it means multiple tables can be used on one worksheet. this means less worksheets in the workbook.
Previously i was using the following to loop through a worksheet and populate a ListView control.
Code:
Sub LoadProfileOptionsList()
Dim Item As Range
Dim currentRow As Long
profOpsLR = LastRow(ws_ProfileOptions)
frmConfigurationBuilder.lstProfileOptions.ListItems.Clear
For Each Item In ws_ProfileOptions.Range("A2:A" & profOpsLR)
If ws_ProfileOptions.Range("A2").value = "" Then
Else
With frmConfigurationBuilder.lstProfileOptions
.ListItems.Add 1, , ws_ProfileOptions.Cells(Item.Row, 1)
.ListItems(1).ListSubItems.Add 1, , ws_ProfileOptions.Cells(Item.Row, 2)
End With
End If
Next Item
End Sub
I am wanting to do this now using a table but seem to be struggling. I have tried the following
Code:
Sub PopulateProfileOptionsList()
Dim dataList As Worksheet
Set dataList = ThisWorkbook.Sheets("DataLists")
With frmGenerator.lstProfileOptions
.ListItems.Add 1, , dataList.Range("ProfileOptions").Cells(1, 2)
.ListItems(1).ListSubItems.Add 1, , dataList.Range("ProfileOptions").Cells(1, 2)
End With
End Sub
However no data is showing up on the ListView control. Ideally i would like the code to loop through and populate all enteries in the table. Once i get that sorted i can replicate the code for my other ListViews.Then move on to resizing the tables as needed.
I can give more information if needed
Many Thanks in advance guys
J.
Regards
J.