Forum Discussion
dlav2001
Dec 06, 2020Copper Contributor
Creating an excel Database from input on Row one
I an trying to create a database that has 8 columns of data. The complicated part is, I want to enter the data on line 1 ONLY ( the first 5 columns of line 1) , and have it add to an ongoing data...
HansVogelaar
Dec 08, 2020MVP
I don't think it's possible to do what you want without VBA code, so it will only work on Windows and MacOS, not on Android or iOS.
The command button runs the following macro when clicked:
Sub AddRecord()
Dim d As Long
Dim m As Long
Dim r As Long
If Range("B14").Value = "" Then
Range("B14").Select
MsgBox "Please enter the bus number!", vbExclamation
Exit Sub
End If
m = Range("C13").End(xlUp).Row - 2
If m = 0 Then
Range("C3").Select
MsgBox "Please enter information in rows 3 and below!", vbExclamation
Exit Sub
End If
d = Val(Range("C14").Value)
If d < 1 Or d > m Then
Range("C14").Select
MsgBox "Please enter a valid day!", vbExclamation
Exit Sub
End If
r = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Range("A" & r).Resize(1, 10).Value = Range("A14").Resize(1, 10).Value
Range("B14:C14").ClearContents
Range("B14").Select
End Sub
You can view the code by activating the Visual Basic Editor (press Alt+F11) and opening Module1 under Modules.
dlav2001
Dec 12, 2020Copper Contributor