I have Created an app that can open up an excel template, let the user enter info and then I save the entered info to my SQL database. What I do for easy cell access I have defined a name for each cell the user can enter info into so i can track down where the info came from. here is my code to save the excel info into SQL.
VB Code:
Private Sub SaveInfo()
On Error GoTo Handler
Dim info() As String, test() As String
Dim strSummary As String
Dim i As Integer
Dim strPricing As String
'MouseIcon = vbHourglass
ReDim info(0)
With xls
Dim a As String, b As String, c As String
'--Set intial and max value for progress bar
pbExcel.Value = 0
pbExcel.Max = .Workbooks(1).Names.Count
'--loop thru all the Excel work book Names
'---This also includes some names that were probably pre-defined
For i = 1 To .Workbooks(1).Names.Count
Debug.Print i
'--This function Figures out which sheet the Name came from.
'--If the Name is not a name I defined the return value is "Stop"
a = GetSheet(.Workbooks(1).Names(i).Name)
Debug.Print .Workbooks(1).Names(i).Name
'--If the defined name leads with "S_" then add value to strSummary
If Left(.Workbooks(1).Names(i).Name, 2) = "S_" Then
The code is a bit ugly, but it works. The only problem is there are roughly 600 cells this thing has to go thru and it take about 15-20 seconds to do so. Can anyone come up with a faster way of doing this?
The reason I Concatinate all the cell values together is, so i can store the value in only one field in my database. The alternative would be to make 600 columns, not a very nice option.
again, any suggestions on how to speed this up would be GREATLY appreciated.
The Excel Template is a Pre-existing Detailed Financial spreadsheet that has tons of info and calculations. I would REALLY REALLY hate having to recreate it in VB.
I guess there is no way of making my way go faster. Maybe I can incrementaly save parts of it. That would help.
Does anyone know how to only select defined Cell names from a particular Page?
excel.application.workbook(1).Names(i).Name will get them from the entire workbook I know for sure.(if you run a loop with i)
Would it be possible for you to take a screen shot of one of the
Excell sheets you are using. I'm very optically oriented and I'm
having difficulty "seeing" the problem.
The simplest way would be to add one more sheet to excel which contains a single range name consisting of all the vaules referenced from the source sheets. This way you would be able to use column names to explain the data value and a simple way to retreive the data from VB