• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Checking for return or enter in an Excel document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking for return or enter in an Excel document


  • Subject: Re: Checking for return or enter in an Excel document
  • From: Stan Cleveland <email@hidden>
  • Date: Wed, 23 May 2012 14:06:47 -0700

On May 23, 2012, at 3:56 AM, Mads Fog Albrechtslund wrote:

Try this, a modified version of Jan's script.

Accessing data cell by cell in Excel is somewhat slow. It's much faster to grab the entire contents of the document, cycle through the resulting list of lists, then write all the data back to Excel after fixing the return characters. 

With that in mind, below is another modification of Jan's/Mads' script. This version also eliminates the nesting of tell application commands, which is best to avoid.

Stan C.

set TheReturn to ASCII character 13
set TheReplacement to " "
tell application "Microsoft Excel"
set sheetData to formula of used range of active sheet -- grab all data from Excel
end tell
repeat with r from 1 to (length of sheetData)
set thisRow to item r of sheetData
repeat with c from 1 to (length of thisRow)
set theCellValue to item c of thisRow
if theCellValue contains TheReturn then
tell application "ASObjC Runner"
set theString to replace string (ASCII character 13) in item theCellValue replacing with TheReplacement
end tell
set item c of item r of sheetData to theString -- update the cell
end if
end repeat
end repeat
tell application "Microsoft Excel"
set formula of used range of active sheet to sheetData -- push all data back to Excel
end tell

 _______________________________________________
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

References: 
 >Checking for return or enter in an Excel document (From: Bert Groeneveld <email@hidden>)
 >Re: Checking for return or enter in an Excel document (From: Jan-Bultereys <email@hidden>)
 >Re: Checking for return or enter in an Excel document (From: Mads Fog Albrechtslund <email@hidden>)

  • Prev by Date: Re: Filtering Out Missing Value
  • Next by Date: Re: Filtering Out Missing Value
  • Previous by thread: Re: Checking for return or enter in an Excel document
  • Next by thread: Re: Checking for return or enter in an Excel document
  • Index(es):
    • Date
    • Thread