***Thank you for fixing the code input!!! Now I know***
I have this working just fine, and it is just a project to see if I can make a front end in excel as most people can run excel and not all have Access loaded. It would be a input form that is more user friendly but would put said content in a worksheet for me to upload to a sql server.
I currently have a WKS1("Input") which is user interface and input form / area. WKS2("CSV") is where data is stored once submitted so that it can be easily updated to a database when I wish. WKS 3(Data Sheet") I have my saved variables in named ranges for drop downs in the majority of my input cells.
I include both sets of code, one is a clear value button that I found source code for clearing the data validation selections, and then added the part to clear text values of two other cells (B3,B15). The other is my submit button, which I got done by myself, but I am sure there is some way to greatly reduce the code, or maybe not since I do not use ranges, just non sequential cells. Only way I could have a blank is if they left B3 Name or B15 description blank.
//Reset Button
Sub resetButton_Click()
Dim rVal As Range
Dim rCell As Range
Dim rList As Range
Dim rName As Range
Dim rDescr As Range
On Error Resume Next
Set rName = Range("B3")
Set rDescr = Range("B15")
Set rVal = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
rName = ClearContents
rDescr = ClearContents
If Not rVal Is Nothing Then
For Each rCell In rVal
rCell.ClearContents
With rCell.Validation
If .Type = xlValidateList Then
If Left(.Formula1, 1) = "=" Then
Set rList = ActiveWorkbook.Names(Right(.Formula1, Len(.Formula1) - 1)).RefersToRange
rCell.Value = rList.Cells(1, 1).Value
Else
rCell.Value = Left(.Formula1, InStr(1, .Formula1, ",") - 1)
End If
End If
End With
Next rCell
End If
End Sub
//Submit Button
//First line is something I was trying but could not get it functional so went with the other which I came up with myself.
Private Sub submitButton_Click()
'Worksheets("Input").Range("B3").Copy Destination:=Worksheets("CSV").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial
Worksheets("CSV").Range("a6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("B3").Value
Worksheets("CSV").Range("b6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("B5").Value
Worksheets("CSV").Range("c6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("B7").Value
Worksheets("CSV").Range("d6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("B9").Value
Worksheets("CSV").Range("e6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("B11").Value
Worksheets("CSV").Range("f6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("B13").Value
Worksheets("CSV").Range("g6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("E3").Value
Worksheets("CSV").Range("h6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("E5").Value
Worksheets("CSV").Range("i6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("E7").Value
Worksheets("CSV").Range("j6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("E9").Value
Worksheets("CSV").Range("k6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("E11").Value
Worksheets("CSV").Range("l6000").End(xlUp).Offset(1, 0).Value = Worksheets("Input").Range("B15").Value
End Sub
Bookmarks