Creating Simple Form in Microsoft Excel using Macro VBA
У вашего броузера проблема в совместимости с HTML5
This video show you how to create a very simple form using Macro VBA. It is very basic, showing you:
1. Activate Developer Tab ( Macro VBA menu )
2. Inserting Form / Active X Component
3. Assign Macro to Form
4. Sample saving data from form to excel
5. Sample if then and loop command
6. Using MsgBox and TextBox and Command Button
Here is the detail script of Macro VBA for Microsoft Excel
Sub Button1_Click()
Dim curPos As Long
Dim MaxRow As Long
Dim LastPos As Boolean
Dim DataisFull As Boolean
MaxRow = 1000000
curPos = 2
LastPos = False
DataisFull = False
Do While Not LastPos
If Sheets("Data").Range("A" & curPos) = "" Then
LastPos = True
Else
curPos = curPos + 1
If curPos > MaxRow Then 'greater then
LastPos = True
DataisFull = True
End If
End If
Loop
If DataisFull Then
MsgBox "Database full", vbCritical
Else
Sheets("Data").Range("A" & curPos) = curPos - 1
Sheets("Data").Range("B" & curPos) = Sheets("Form").Range("C2")
Sheets("Data").Range("C" & curPos) = Sheets("Form").TextBox1.Text
Sheets("Form").TextBox1.Text = ""
Sheets("Form").Range("C2") = ""
DoEvents
MsgBox "Data is Saved
End If
End Sub