PC Review


Reply
Thread Tools Rate Thread

Adjusting the range of a script

 
 
jsd219
Guest
Posts: n/a
 
      31st Oct 2006
I know i posted this a day or two ago but for whatever reason all of my
newsgroups have not been showing up so i have to repost this.

I have a script the searches starting in column A1 all the way through
the sheet and then through all the other sheets in the workbook. I need
the script to only run in one sheet "Resources", and in only one,
specified, column, in addition I would like the script to go back the
the starting position (position #1 of the specified column) once it has
finished.

I have look through the code but am a newbe and can not figure out how
to make these adjustments properly. Thank in advance :-)

Sub DeleteThisStuff()

Dim lngRow As Long
Dim strSearchString As String
Dim lngRowCount As Long
Dim intStartingPosition As Integer
Dim intEndingPosition As Integer
Dim lngStartingRow As Long
Dim lngEndingRow As Long
Dim blnStartFound As Boolean
Dim blnEndFound As Boolean
Dim rngSearch As Range
Dim intBlankCounter As Integer
Dim lngLastBlankRow As Integer
'Set rngSearch = Me.Cells
Dim rngCurrent As Range
Dim MySheet As Worksheet
blnStartFound = False
blnEndFound = True
intBlankCounter = 0

'MsgBox ActiveWorkbook.Name
For Each MySheet In Worksheets
MySheet.Activate
'If MySheet.Name = "ch9" And lngRow = 196 Then Stop
'Debug.Print MySheet.Name
lngRowCount = MySheet.Rows.Count
For lngRow = 1 To lngRowCount
strSearchString = MySheet.Cells(lngRow, 1).Text
'Debug.Print strSearchString
' MySheet.Cells(lngRow, 1).Select
' Set rngCurrent = MySheet.Range(Cells(lngRow, 1),
Cells(lngRow, 1))
If blnStartFound = False And blnEndFound = True Then
intStartingPosition = InStr(1, strSearchString,
"#NAME?", vbBinaryCompare)
If intStartingPosition <> 0 Then
' yay!!! we found it
lngStartingRow = lngRow
blnStartFound = True
blnEndFound = False
GoTo NextRow
End If
ElseIf blnEndFound = False And blnStartFound = True Then
intEndingPosition = InStr(1, strSearchString,
"Copyright")
If intEndingPosition <> 0 Then
' yay!!!
lngEndingRow = lngRow
blnEndFound = True
Set rngSearch = MySheet.Range(Cells(lngStartingRow,
1), Cells(lngEndingRow, 1))
rngSearch.Select
rngSearch.Delete
lngStartingRow = 0
lngEndingRow = 0
lngRow = 1
blnStartFound = False
GoTo NextRow
End If
End If

If Len(strSearchString) = 0 Then
If lngLastBlankRow = (lngRow - 1) Then intBlankCounter
= intBlankCounter + 1
lngLastBlankRow = lngRow
If intBlankCounter > 5 Then
intBlankCounter = 0
lngRow = 0
GoTo NextSheet
End If
End If
NextRow:
Next lngRow
NextSheet:
intBlankCounter = 0
lngRow = 0
lngLastBlankRow = 0
Next MySheet
End Sub

God bless
jsd219

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adjusting To Current Row Range in Marco tmdrake Microsoft Excel Misc 0 19th May 2008 09:19 PM
Adjusting lookup range =?Utf-8?B?U25hcmE=?= Microsoft Excel Discussion 2 1st Oct 2007 05:20 PM
Java Script question on posting the date and adjusting the font Mark M S Microsoft Frontpage 3 17th Nov 2006 10:13 PM
Adjusting a formula cell range =?Utf-8?B?SmFtaWU=?= Microsoft Excel Misc 1 26th May 2006 05:00 PM
adjusting a VB script to my needs DPeter2101 Microsoft Excel Programming 4 19th Dec 2005 04:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:15 AM.