From: Li Chen Date: 2006-12-15T12:03:51+09:00 Subject: Re: ruby/ole excel delete row? Eric Ching wrote: > How do I delete a row in an excel spreadsheet with win32ole? > > I want to loop through some rows and delete a row if a cell in the row > contains a certain value. > > Here's the loop I am using: > > excel.Range("h2:h305").each do |cell| > if cell.Value == "blah" > # DELETE ROW HERE > end > end Hi, Try this: array=[] worksheet1.Range("A1:L40").each do |cell| if cell.Value=~/A/ ad=cell.Address array=ad.scan(/\w+/) column,row=array worksheet1.Rows("#{row}:#{row}").Delete("Shift"=> Excel_constants::XlUp) end end -- Posted via http://www.ruby-forum.com/.