LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Tweaking Code - Experts Only!

Hi...

Each monday I get a spreadsheet that's 10,000 lines deep
and 100 across. My task is to locate certain values
within any cell (within any column or any row) and then
delete the row in which the value was found. Typically I
have about 300 values to find and it takles me around 4
hours - I've reached breaking point!

Ideally I'd like to click on a macro button that will
launch an input box that will allow me to for example
enter the name Jones. When I click OK on the input box I
want a macro to run through the entire sheet locating
every occourance Jones and deleting every row in which
the value Jones appear (lifting cells upwards of course)

The code below is as far as I've got (thanks from Nigel)
but whilst this code cycles nicely it doesn't actually
locate the values or text striongs that I need to be
found and then removed, it ignores all the Jones values
and then tells me that no JOnes values exists and that no
rows have been removed...Why? Can anyone help?

Public Sub remove()
Worksheets("Sheet1").Activate
Dim lastrow As Long
Dim lastcol As Long
Dim sString As String
sString = InputBox("Delete Row(s) were cell has this
value.")
lastrow = ActiveSheet.UsedRange.Rows.Count
lastcol = ActiveSheet.UsedRange.Columns.Count
Application.ScreenUpdating = False
Dim ir As Long, ic As Long, rd As Long
For ir = lastrow To 1 Step -1
For ic = lastcol To 1 Step -1
If Cells(ir, ic).Value = sString Then
Rows(ir).Delete shift:=xlUp
rd = rd + 1
End If
Next ic
Next ir
Application.ScreenUpdating = True
MsgBox "Deleted: " & rd & " rows"
End Sub

Thanks

Gordon

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with tweaking formula Johndb Excel Worksheet Functions 5 July 24th 09 11:28 PM
macro tweaking jatman Excel Discussion (Misc queries) 1 March 21st 08 09:13 PM
Tweaking formula? Richard Excel Discussion (Misc queries) 2 August 14th 06 12:52 PM
combining 2+ wkbks into 1. Code needs tweaking please ian123[_31_] Excel Programming 12 January 3rd 04 11:20 PM
Searching range for value (code written but needs 'tweaking'!) ian123[_26_] Excel Programming 8 December 23rd 03 05:19 PM


All times are GMT +1. The time now is 02:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"