#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default do..loop

I would like to compare each cell in column B (which is month) with cell A1
(showing this month). If the text in cell A1 is same as column B, then keep
the row. Otherwise, delete the row. I don't what's wrong with below coding!!
Anyone can help me or any other good sugguestion?
Thank you for your help.

Range("B6").Select

Do

If ACTIVCECELL.Text = Range("A1").Text Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop Until ActiveCell.Text = "END"

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default do..loop

try:

If ACTIVeCELL= Range("A1") Then

"Anna" wrote:

I would like to compare each cell in column B (which is month) with cell A1
(showing this month). If the text in cell A1 is same as column B, then keep
the row. Otherwise, delete the row. I don't what's wrong with below coding!!
Anyone can help me or any other good sugguestion?
Thank you for your help.

Range("B6").Select

Do

If ACTIVCECELL.Text = Range("A1").Text Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop Until ActiveCell.Text = "END"

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default do..loop

For i = Cells(Rows.Count, "B").End(xlUp).Row To 6 Step -1
If Cells(i, "B").Text < Range("A1").Text Then
Cells(i, "B").Delete Shift:=xlUp
End If
Next i


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Anna" wrote in message
...
I would like to compare each cell in column B (which is month) with cell A1
(showing this month). If the text in cell A1 is same as column B, then
keep
the row. Otherwise, delete the row. I don't what's wrong with below
coding!!
Anyone can help me or any other good sugguestion?
Thank you for your help.

Range("B6").Select

Do

If ACTIVCECELL.Text = Range("A1").Text Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop Until ActiveCell.Text = "END"



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default do..loop

The coding seems delete cells (in column b) but not the entire row!! Would
you please tell me what should I do?
Thanks

"Toppers" wrote:

try:

If ACTIVeCELL= Range("A1") Then

"Anna" wrote:

I would like to compare each cell in column B (which is month) with cell A1
(showing this month). If the text in cell A1 is same as column B, then keep
the row. Otherwise, delete the row. I don't what's wrong with below coding!!
Anyone can help me or any other good sugguestion?
Thank you for your help.

Range("B6").Select

Do

If ACTIVCECELL.Text = Range("A1").Text Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop Until ActiveCell.Text = "END"

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default do..loop

And to delete the entire row:

For i = Cells(Rows.Count, "B").End(xlUp).Row To 6 Step -1
If Cells(i, "B").Text < Range("A1").Text Then
rows(i).Delete
End If
Next i

Bob Phillips wrote:

For i = Cells(Rows.Count, "B").End(xlUp).Row To 6 Step -1
If Cells(i, "B").Text < Range("A1").Text Then
Cells(i, "B").Delete Shift:=xlUp
End If
Next i

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Anna" wrote in message
...
I would like to compare each cell in column B (which is month) with cell A1
(showing this month). If the text in cell A1 is same as column B, then
keep
the row. Otherwise, delete the row. I don't what's wrong with below
coding!!
Anyone can help me or any other good sugguestion?
Thank you for your help.

Range("B6").Select

Do

If ACTIVCECELL.Text = Range("A1").Text Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop Until ActiveCell.Text = "END"


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default do..loop

judging from her code, she didn't want to do that.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dave Peterson" wrote in message
...
And to delete the entire row:

For i = Cells(Rows.Count, "B").End(xlUp).Row To 6 Step -1
If Cells(i, "B").Text < Range("A1").Text Then
rows(i).Delete
End If
Next i

Bob Phillips wrote:

For i = Cells(Rows.Count, "B").End(xlUp).Row To 6 Step -1
If Cells(i, "B").Text < Range("A1").Text Then
Cells(i, "B").Delete Shift:=xlUp
End If
Next i

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Anna" wrote in message
...
I would like to compare each cell in column B (which is month) with cell
A1
(showing this month). If the text in cell A1 is same as column B, then
keep
the row. Otherwise, delete the row. I don't what's wrong with below
coding!!
Anyone can help me or any other good sugguestion?
Thank you for your help.

Range("B6").Select

Do

If ACTIVCECELL.Text = Range("A1").Text Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop Until ActiveCell.Text = "END"


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default do..loop

Yep. But on the follow up to Toppers, she asked how to change his code to
delete the entire row.

So I jumped in <bg.

Bob Phillips wrote:

judging from her code, she didn't want to do that.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dave Peterson" wrote in message
...
And to delete the entire row:

For i = Cells(Rows.Count, "B").End(xlUp).Row To 6 Step -1
If Cells(i, "B").Text < Range("A1").Text Then
rows(i).Delete
End If
Next i

Bob Phillips wrote:

For i = Cells(Rows.Count, "B").End(xlUp).Row To 6 Step -1
If Cells(i, "B").Text < Range("A1").Text Then
Cells(i, "B").Delete Shift:=xlUp
End If
Next i

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Anna" wrote in message
...
I would like to compare each cell in column B (which is month) with cell
A1
(showing this month). If the text in cell A1 is same as column B, then
keep
the row. Otherwise, delete the row. I don't what's wrong with below
coding!!
Anyone can help me or any other good sugguestion?
Thank you for your help.

Range("B6").Select

Do

If ACTIVCECELL.Text = Range("A1").Text Then
ActiveCell.Offset(1, 0).Select
Else
Selection.Delete Shift:=xlUp
End If
Loop Until ActiveCell.Text = "END"


--

Dave Peterson


--

Dave Peterson
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
DO LOOP in VBA Brettjg Excel Discussion (Misc queries) 5 April 24th 07 12:42 AM
Do Loop BobBarker Excel Worksheet Functions 0 August 23rd 05 08:33 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 08:44 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 07:45 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 06:54 PM


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

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

About Us

"It's about Microsoft Excel"