Hi!
I'm using excel 2003 english version in windows 7.
I have a paperform where we take notes of different things through a period. My wish is to have the same information saved on a spreadsheet, so it would be easy to search through for information and print out a new updated paperform if we looses the original.
So I have made two sheets, one with the paperform layout called FORM 1 and one with all the values called DATABASE.
2500 rows with a unique ID for each paperform and 200 columns where the different values will be recorded to.
When a user wants to update my thought was that he could do it best on the paperform sheet, by just picking from a drop down list what paperform he wants to update or look at.
I have made a cell with validation format using UNIQUE_ID range as a list, When the user changes this he will get the right values in the paperform from the DATABASE sheet.
I have place this formula in each cell I want to update:
And so long this is working perfect!
But the trouble comes when I want to send or update the new values from the paperform sheet into the database. I have made a update button with the following command:
have been reading and testing others VBA codes and now I am very pleased that I have got it to work. But it's turned out to be very slow solution.
Also the next operation that I have, turning back the paperform to it's original with all it's formulas is very slow.
So I'm hoping that my code are containing something useless that I can skip so it will get faster.
To make an update now it will take about 30 sec before it's done.
So don't hesitate to tell me how stupid I have been!
I'm using excel 2003 english version in windows 7.
I have a paperform where we take notes of different things through a period. My wish is to have the same information saved on a spreadsheet, so it would be easy to search through for information and print out a new updated paperform if we looses the original.
So I have made two sheets, one with the paperform layout called FORM 1 and one with all the values called DATABASE.
2500 rows with a unique ID for each paperform and 200 columns where the different values will be recorded to.
When a user wants to update my thought was that he could do it best on the paperform sheet, by just picking from a drop down list what paperform he wants to update or look at.
I have made a cell with validation format using UNIQUE_ID range as a list, When the user changes this he will get the right values in the paperform from the DATABASE sheet.
I have place this formula in each cell I want to update:
Code:
"=INDEX(DATABASE_FIELD;MATCH(SEARCH;UNIQUE_ID;0);MATCH("INFO 1";DATABASE!$1:$1;0))"
And so long this is working perfect!
But the trouble comes when I want to send or update the new values from the paperform sheet into the database. I have made a update button with the following command:
Code:
Private Sub cmdUPDATE_Click()
Dim vreg As String, drow As Integer, c As Range
'SEARCH is cell B3, and is used in FORM 1 to choose what row I want to work with or look at.
'SEARCH has a validation setting, saying that I can choose from a list called UNIQUE_ID.
Let vreg = Range("SEARCH").Value
With Sheets("DATABASE").Range("UNIQUE_ID")
Set c = .Find(vreg, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
drow = c.Row
End If
End With
With Me
'Gathering information from the sheet FORM 1. into the sheet DATABASE.
'If any of the cells have been changed in FORM 1, they will be updated with the new values into the DATABASE sheet.
Sheets("DATABASE").Cells(drow, 2).Value = Range("D5").Value
Sheets("DATABASE").Cells(drow, 3).Value = Range("D7").Value
Sheets("DATABASE").Cells(drow, 4).Value = Range("D9").Value
Sheets("DATABASE").Cells(drow, 5).Value = Range("G5").Value
Sheets("DATABASE").Cells(drow, 6).Value = Range("G7").Value
Sheets("DATABASE").Cells(drow, 7).Value = Range("G9").Value
Sheets("DATABASE").Cells(drow, 8).Value = Range("E13").Value
Sheets("DATABASE").Cells(drow, 9).Value = Range("F13").Value
Sheets("DATABASE").Cells(drow, 10).Value = Range("E16").Value
Sheets("DATABASE").Cells(drow, 11).Value = Range("F16").Value
Sheets("DATABASE").Cells(drow, 12).Value = Range("E19").Value
Sheets("DATABASE").Cells(drow, 13).Value = Range("F19").Value
'If cells in FORM 1 have been changed, they will have lost their formula, and this code will bring it back to the default.
'DATABASE_FIELD is the the whole range in DATABASE sheet with information.
Range("D5").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 1"",DATABASE!$1:$1,0))"
Range("D7").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 2"",DATABASE!$1:$1,0))"
Range("D9").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 3"",DATABASE!$1:$1,0))"
Range("G5").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 4"",DATABASE!$1:$1,0))"
Range("G7").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 5"",DATABASE!$1:$1,0))"
Range("G9").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 6"",DATABASE!$1:$1,0))"
Range("E13").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 7"",DATABASE!$1:$1,0))"
Range("F13").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 8"",DATABASE!$1:$1,0))"
Range("E16").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 9"",DATABASE!$1:$1,0))"
Range("F16").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 10"",DATABASE!$1:$1,0))"
Range("E19").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 11"",DATABASE!$1:$1,0))"
Range("F19").Formula = "=INDEX(DATABASE_FIELD,MATCH(SEARCH,UNIQUE_ID,0),MATCH(""INFO 12"",DATABASE!$1:$1,0))"
End With
End Sub
have been reading and testing others VBA codes and now I am very pleased that I have got it to work. But it's turned out to be very slow solution.
Also the next operation that I have, turning back the paperform to it's original with all it's formulas is very slow.
So I'm hoping that my code are containing something useless that I can skip so it will get faster.
To make an update now it will take about 30 sec before it's done.
So don't hesitate to tell me how stupid I have been!
