Excel insanity
Excel insanity
- Subject: Excel insanity
- From: David Crowe via AppleScript-Users <email@hidden>
- Date: Thu, 26 Mar 2020 20:39:30 -0600
I am trying to insert some cells into an Excel spreadsheet.
The following code works if my spreadsheet and worksheet are at the front:
tell application "Microsoft Excel"
tell workbook "Update Email List.xlsx"
tell worksheet "TIM Emails"
set searchRange to range ("C2:C9999")
try
set foundRange to find searchRange what
theEmailAddress
-- If the email address is not present an error
will mean that the following code is not executed
tell me
activate
display dialog "Email address <" &
theEmailAddress & "> already in file" giving up after 3
return
end tell
end try
-- Find first blank row
set blank to ""
set searchRange to range ("C2:C9999")
set foundRange to find searchRange what blank
set theRow to first row index of foundRange as text
set value of cell ("A" & theRow) to FirstName
set value of cell ("B" & theRow) to LastName
set value of cell ("C" & theRow) to theEmailAddress
set value of cell ("D" & theRow) to DateString
set value of cell ("E" & theRow) to "Email"
end tell
end tell
end tell
Otherwise, it attempts to modify whatever sheet is at the front. It is if the
“tell workbook” and “tell worksheet” weren’t present.
If I put “TIM Emails!” in front of every address I get an error (although I
have another script for which this works, see belowu ).
So this following code works (and uses the right sheet as long as the sheet
name is put in every range specification):
-- Account Information
tell application "Microsoft Excel"
tell workbook "CBRS ID Assignments.xlsx"
-- Account Information
tell worksheet "Account"
set searchRange to range ("Account!B1:B9999")
try
set foundRange to find searchRange what
AccountName
on error errmsg number errnum
tell me
display dialog "Cannot find account
containing: " & AccountName
return ("")
end tell
end try
etc etc
- David Crowe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden