Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Go to next line

I need to add some formatting in a spreadsheet in the row after a specific
value is found

The word "New" is my target word so

What I need to do is is go to the line after each time the word New is found

Any suggestions
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Go to next line

Your question is a little vague but perhaps this will get you started...

Public Sub FindNew()
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String
Dim rngToSearch As Range

Set rngToSearch = Sheets("Sheet1").Columns("A")
Set rngFound = rngToSearch.Find(What:="New", _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "New was not found."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.Offset(1, 0).EntireRow.Interior.ColorIndex = 34
End If
End Sub
--
HTH...

Jim Thomlinson


"Nigel" wrote:

I need to add some formatting in a spreadsheet in the row after a specific
value is found

The word "New" is my target word so

What I need to do is is go to the line after each time the word New is found

Any suggestions

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Go to next line


Once I have found it I need to move to the next row apply some formatting
and then move on the the next instance of new


"Jim Thomlinson" wrote:

Your question is a little vague but perhaps this will get you started...

Public Sub FindNew()
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String
Dim rngToSearch As Range

Set rngToSearch = Sheets("Sheet1").Columns("A")
Set rngFound = rngToSearch.Find(What:="New", _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "New was not found."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.Offset(1, 0).EntireRow.Interior.ColorIndex = 34
End If
End Sub
--
HTH...

Jim Thomlinson


"Nigel" wrote:

I need to add some formatting in a spreadsheet in the row after a specific
value is found

The word "New" is my target word so

What I need to do is is go to the line after each time the word New is found

Any suggestions

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Go to next line

OK I am sorry I do need to be more specific

In column A the value will be either new or old ie a2 value is old a3 value
is old a4 value is new - a5 is blank a6 is old and so on


after the value new there will aways be a blank line and then after that a
new line of data

What I need to do is go to the first blank line and add some calculations
then move on and find the next intance of new - move to next line do
calculations - continue on to next blank line until the last row of data is
reached

"Jim Thomlinson" wrote:

Your question is a little vague but perhaps this will get you started...

Public Sub FindNew()
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String
Dim rngToSearch As Range

Set rngToSearch = Sheets("Sheet1").Columns("A")
Set rngFound = rngToSearch.Find(What:="New", _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "New was not found."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.Offset(1, 0).EntireRow.Interior.ColorIndex = 34
End If
End Sub
--
HTH...

Jim Thomlinson


"Nigel" wrote:

I need to add some formatting in a spreadsheet in the row after a specific
value is found

The word "New" is my target word so

What I need to do is is go to the line after each time the word New is found

Any suggestions

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Go to next line

Take a look at this...

Public Sub FindNew()
Dim rngFound As Range
Dim strFirstAddress As String
Dim rngToSearch As Range

Set rngToSearch = Sheets("Sheet1").Columns("A")
Set rngFound = rngToSearch.Find(What:="New", _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "New was not found."
Else
strFirstAddress = rngFound.Address
Do
rngFound.Offest(1,0).Select
msgbox "Tada... time to do my stuff"
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
End If
End Sub

--
HTH...

Jim Thomlinson


"Nigel" wrote:

OK I am sorry I do need to be more specific

In column A the value will be either new or old ie a2 value is old a3 value
is old a4 value is new - a5 is blank a6 is old and so on


after the value new there will aways be a blank line and then after that a
new line of data

What I need to do is go to the first blank line and add some calculations
then move on and find the next intance of new - move to next line do
calculations - continue on to next blank line until the last row of data is
reached

"Jim Thomlinson" wrote:

Your question is a little vague but perhaps this will get you started...

Public Sub FindNew()
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String
Dim rngToSearch As Range

Set rngToSearch = Sheets("Sheet1").Columns("A")
Set rngFound = rngToSearch.Find(What:="New", _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "New was not found."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.Offset(1, 0).EntireRow.Interior.ColorIndex = 34
End If
End Sub
--
HTH...

Jim Thomlinson


"Nigel" wrote:

I need to add some formatting in a spreadsheet in the row after a specific
value is found

The word "New" is my target word so

What I need to do is is go to the line after each time the word New is found

Any suggestions



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Go to next line

Look in the vba help index for FIND and FINDNEXT.

--
Don Guillett
SalesAid Software

"Nigel" wrote in message
...
I need to add some formatting in a spreadsheet in the row after a specific
value is found

The word "New" is my target word so

What I need to do is is go to the line after each time the word New is
found

Any suggestions


Reply
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
How to convert a dotted line to a solid line in a line graph Sharlz Charts and Charting in Excel 1 January 14th 09 04:51 AM
Make a line in a bar chart, and change color of any bars that exceed the line MarkM Excel Discussion (Misc queries) 4 July 5th 06 04:06 PM
coloring overy other line without doing so line by line gen Excel Worksheet Functions 5 April 1st 05 10:38 PM
Macro problem on, Yellowed line - previous line or next line. Ed Excel Programming 7 March 29th 05 09:37 PM
Reads entire *.txt file into string opposed to a desired line by line input. ej_user Excel Programming 3 October 11th 04 07:15 PM


All times are GMT +1. The time now is 03:43 PM.

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"