VBA MOD01 Excel Input Box Method
Task 1 - Add data , add Amount
Sub Excel_InputBox()
Dim Cname As String
Dim NextRow As Long
Dim CAmount As Long
Cname = InputBox("CustomerName", "Name Please..")
NextRow = Cells(Rows.Count, 1).End(xlUp).Row+ 1
Range("A" & NextRow).Value = Cname
CAmount = Excel.Application _
.InputBox(Prompt:="Please Input Amount", Title:="Amount..", Type:=1)
Range("B" & NextRow).Value = CAmount
Debug.Print NextRow
End Sub
Task 2 : Identify Blank Cells
Sub Excel_InputBox_Range()
Dim myRange As Range
Dim cellBlank As Long, cellNum As Long, cellOther As Long
On Error GoTo leave
Set myRange = Application.InputBox("Count the number of cells", "Checking Cells...", , , , , , 8)
'Debug.Print myRange.Address
cellBlank = Excel.WorksheetFunction.CountBlank(myRange)
cellNum = Excel.WorksheetFunction.Count(myRange)
cellOther = Excel.WorksheetFunction.CountA(myRange) - cellNum
MsgBox cellBlank & "cells are blank." & vbNewLine _
& cellNum & "cell have numbers." & vbNewLine _
& cellOther & "cells are non numeric "
leave:
End Sub
Comments
Post a Comment