Discussion Locked

Run code on an Excel spreadsheet

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have an Excel spreadsheet.
I pasted a button on the spreadsheet.
I copied code to the button.
I need to know how to run the code.
Thank you.

2 replies

by dklippert

Create the button using the Form toolbar. A dialog will appear to assign a macro to run on button click

by hurdk

I need to execute instructions such as

Dim dbs As database
Dim strSQL As String
Dim fld As Field
Dim rs1 As Recordset
On Error Resume Next
Set dbs = CurrentDb()
fld.Attributes = dbAutoIncrField
With tdf
.Fields.Append.CreateField("PersonID,dbLong")
End With

strSQL = "SELECT PersonID FROM .. ORDER ... "
DoCmd.RunSQL (strSQL)

I get errors with this type of coding

This discussion is closed to new replies.