Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Moving to first Instance of a Value

I just need to move down column B to find the 1st cell containing a word.
Then I'll be able to get it's row and column.

Any help?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Moving to first Instance of a Value

This moves donw from the activecell cell.
do until activecell.value = ""
ActiveCell.Offset(1, 0).Range("A1").Select
if activecell.value = "Text" then
Z= activecell.row
end if
loop
"scott" wrote:

I just need to move down column B to find the 1st cell containing a word.
Then I'll be able to get it's row and column.

Any help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving to first Instance of a Value

Well, the column is Column B. For the row

Range("B1").Select
do while lcase(ActiveCell) < "word" and ActiveCell < ""
activeCell.Offset(1,0).Select
Loop
if ActiveCell = "Word" then
myrow = activeCell.row
mycolumn = activecell.column
end if

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I just need to move down column B to find the 1st cell containing a word.
Then I'll be able to get it's row and column.

Any help?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Moving to first Instance of a Value

I need a little help. In cell B6 the value = "Branch". I'm just trying to
say, "Start at B1, find 1st cell that contains Branch and delete all rows
between B1 and 1 row before 1st cell containing Branch".

Code runs an infinate loop. I tried several variations of suggested code,
but can't figure where i'm wrong.

Function CleanHeader()

dim r as integer, sString as string
sString = "Branch"

Do until activecell.value = ""
' ActiveCell.Offset(1,0).Range("A1").Select
Range("B1").Select

If activecell.value = sString Then
r= activecell.row
End If
loop

Dim startCell As Range, endCell As Range

ActiveCell.Offset(1,0).Range("A1").Select

Set startCell = ActiveCell
Set endCell = startCell.Offset(r-1, 0)
Range(startCell, endCell).EntireRow.Delete
End Function



"scott" wrote in message
...
I just need to move down column B to find the 1st cell containing a word.
Then I'll be able to get it's row and column.

Any help?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving to first Instance of a Value

Sub Tester3()
Dim rng As Range, rng1 As Range
Set rng = Cells(Rows.Count, 2).End(xlUp)
Set rng = Range(Range("B1"), rng)
Set rng1 = rng.Find(What:="Branch", _
After:=Range("B1"), _
LookIn:=xlValues, _
Lookat:=xlWhole, _
SearchOrder:=xlByRows)
If Not rng1 Is Nothing Then
Range(Range("B2"), _
rng1.Offset(-1, 0)).EntireRow _
.Delete
Else
MsgBox "Branch not found"
End If

End Sub
--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I need a little help. In cell B6 the value = "Branch". I'm just trying to
say, "Start at B1, find 1st cell that contains Branch and delete all rows
between B1 and 1 row before 1st cell containing Branch".

Code runs an infinate loop. I tried several variations of suggested code,
but can't figure where i'm wrong.

Function CleanHeader()

dim r as integer, sString as string
sString = "Branch"

Do until activecell.value = ""
' ActiveCell.Offset(1,0).Range("A1").Select
Range("B1").Select

If activecell.value = sString Then
r= activecell.row
End If
loop

Dim startCell As Range, endCell As Range

ActiveCell.Offset(1,0).Range("A1").Select

Set startCell = ActiveCell
Set endCell = startCell.Offset(r-1, 0)
Range(startCell, endCell).EntireRow.Delete
End Function



"scott" wrote in message
...
I just need to move down column B to find the 1st cell containing a word.
Then I'll be able to get it's row and column.

Any help?







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Moving to first Instance of a Value

for some reason, it doesn't find the word branch in B6. I noticed you set
rng twice. what do you think?


"Tom Ogilvy" wrote in message
...
Sub Tester3()
Dim rng As Range, rng1 As Range
Set rng = Cells(Rows.Count, 2).End(xlUp)
Set rng = Range(Range("B1"), rng)
Set rng1 = rng.Find(What:="Branch", _
After:=Range("B1"), _
LookIn:=xlValues, _
Lookat:=xlWhole, _
SearchOrder:=xlByRows)
If Not rng1 Is Nothing Then
Range(Range("B2"), _
rng1.Offset(-1, 0)).EntireRow _
.Delete
Else
MsgBox "Branch not found"
End If

End Sub
--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I need a little help. In cell B6 the value = "Branch". I'm just trying to
say, "Start at B1, find 1st cell that contains Branch and delete all rows
between B1 and 1 row before 1st cell containing Branch".

Code runs an infinate loop. I tried several variations of suggested code,
but can't figure where i'm wrong.

Function CleanHeader()

dim r as integer, sString as string
sString = "Branch"

Do until activecell.value = ""
' ActiveCell.Offset(1,0).Range("A1").Select
Range("B1").Select

If activecell.value = sString Then
r= activecell.row
End If
loop

Dim startCell As Range, endCell As Range

ActiveCell.Offset(1,0).Range("A1").Select

Set startCell = ActiveCell
Set endCell = startCell.Offset(r-1, 0)
Range(startCell, endCell).EntireRow.Delete
End Function



"scott" wrote in message
...
I just need to move down column B to find the 1st cell containing a
word.
Then I'll be able to get it's row and column.

Any help?







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving to first Instance of a Value

I think it worked fine for me. maybe you have more than just Branch in B6.
Try changing

Lookat:=xlWhole, _


to

Lookat:=xlPart, _

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
for some reason, it doesn't find the word branch in B6. I noticed you set
rng twice. what do you think?


"Tom Ogilvy" wrote in message
...
Sub Tester3()
Dim rng As Range, rng1 As Range
Set rng = Cells(Rows.Count, 2).End(xlUp)
Set rng = Range(Range("B1"), rng)
Set rng1 = rng.Find(What:="Branch", _
After:=Range("B1"), _
LookIn:=xlValues, _
Lookat:=xlWhole, _
SearchOrder:=xlByRows)
If Not rng1 Is Nothing Then
Range(Range("B2"), _
rng1.Offset(-1, 0)).EntireRow _
.Delete
Else
MsgBox "Branch not found"
End If

End Sub
--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I need a little help. In cell B6 the value = "Branch". I'm just trying

to
say, "Start at B1, find 1st cell that contains Branch and delete all

rows
between B1 and 1 row before 1st cell containing Branch".

Code runs an infinate loop. I tried several variations of suggested

code,
but can't figure where i'm wrong.

Function CleanHeader()

dim r as integer, sString as string
sString = "Branch"

Do until activecell.value = ""
' ActiveCell.Offset(1,0).Range("A1").Select
Range("B1").Select

If activecell.value = sString Then
r= activecell.row
End If
loop

Dim startCell As Range, endCell As Range

ActiveCell.Offset(1,0).Range("A1").Select

Set startCell = ActiveCell
Set endCell = startCell.Offset(r-1, 0)
Range(startCell, endCell).EntireRow.Delete
End Function



"scott" wrote in message
...
I just need to move down column B to find the 1st cell containing a
word.
Then I'll be able to get it's row and column.

Any help?









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Moving to first Instance of a Value

i tried part, whole to no avail. Branch is in B6 and fartjer down in column
B. I'm just trying to delete the rows between A1 and B6 where Branch appears
first.

Could it be because of proper case?


"Tom Ogilvy" wrote in message
...
I think it worked fine for me. maybe you have more than just Branch in B6.
Try changing

Lookat:=xlWhole, _


to

Lookat:=xlPart, _

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
for some reason, it doesn't find the word branch in B6. I noticed you set
rng twice. what do you think?


"Tom Ogilvy" wrote in message
...
Sub Tester3()
Dim rng As Range, rng1 As Range
Set rng = Cells(Rows.Count, 2).End(xlUp)
Set rng = Range(Range("B1"), rng)
Set rng1 = rng.Find(What:="Branch", _
After:=Range("B1"), _
LookIn:=xlValues, _
Lookat:=xlWhole, _
SearchOrder:=xlByRows)
If Not rng1 Is Nothing Then
Range(Range("B2"), _
rng1.Offset(-1, 0)).EntireRow _
.Delete
Else
MsgBox "Branch not found"
End If

End Sub
--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I need a little help. In cell B6 the value = "Branch". I'm just trying

to
say, "Start at B1, find 1st cell that contains Branch and delete all

rows
between B1 and 1 row before 1st cell containing Branch".

Code runs an infinate loop. I tried several variations of suggested

code,
but can't figure where i'm wrong.

Function CleanHeader()

dim r as integer, sString as string
sString = "Branch"

Do until activecell.value = ""
' ActiveCell.Offset(1,0).Range("A1").Select
Range("B1").Select

If activecell.value = sString Then
r= activecell.row
End If
loop

Dim startCell As Range, endCell As Range

ActiveCell.Offset(1,0).Range("A1").Select

Set startCell = ActiveCell
Set endCell = startCell.Offset(r-1, 0)
Range(startCell, endCell).EntireRow.Delete
End Function



"scott" wrote in message
...
I just need to move down column B to find the 1st cell containing a
word.
Then I'll be able to get it's row and column.

Any help?











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
Moving text around cells without moving boarder lines Dale Excel Discussion (Misc queries) 1 December 15th 09 06:14 PM
How does one name, for instance, A1 as 'last name?' Rev. Benny New Users to Excel 2 October 14th 08 01:58 PM
Arrow Keys Moving Window Frame instead of Moving Between Cells nemmex Excel Discussion (Misc queries) 2 April 9th 07 09:08 AM
First Instance Howard Excel Discussion (Misc queries) 8 March 17th 07 03:05 PM
How do I get rid of a 2nd instance (xls:2)? greenwellies Excel Discussion (Misc queries) 4 April 24th 06 04:44 AM


All times are GMT +1. The time now is 12:50 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"