You can create a series of numbers or dates using the autofill property, as follows:
With Worksheets("Sheet1").Range("A1")
.Value = 1
.AutoFill Destination:=.Resize(20, 1), Type:=xlFillSeries
End WithThis is straightforward. You can omit the column size parameter since there's no change.
tell application "Microsoft Excel" tell range "A1" of worksheet "Sheet1" set value to 1 autofill destination (get resize row size 20) type ¬ fill series end tell end tell
Using validation
Validation restricts user entries into a cell using the Validation object. For instance, an entry can be limited to positive integers, as follows:
With ActiveSheet.Range("A2").Validation
.Delete 'remove current validation object
.Add _
Type:=xlValidateWholeNumber, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlGreater, _
Formula1:="0"
.IgnoreBlank = True
.InputTitle = ""
.ErrorTitle = "Invalid Entry!"
.InputMessage = "Enter an integer > 0"
.ErrorMessage = "The entry MUST be a positive integer."
.ShowInput = True
.ShowError = True
End WithIn AppleScript, you cannot delete a property, only an element. The structure of range is such that validation is a read-only property. You can modify it instead, if need be, with the modify command that uses all the same parameters that add data validation uses. Aside from that qualification, the script is just the same as the macro.
tell application "Microsoft Excel" tell validation of range "A2" of active sheet --can't delete , modify if need be add data validation type validate whole number ¬ alert style valid alert stop ¬ operator operator greater ¬ formula1 "0" set ignore blank to true set input title to "" set error title to "Invalid Entry!" set input message to "Enter an integer > 0" set error message to "The entry MUST be a positive integer." set show input to true set show error to true end tell end tell


