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" |
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" |
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" |
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" |
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 |
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 |
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 |
All times are GMT +1. The time now is 10:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com