![]() |
Do While Problem
I am trying to figure out how to write a macro that will delete all
information in a row for columns A through O, if the current value of column c in that row = 350. I would post some of the code I have tried but it is a huge mess. I feel like this should be pretty simple. If anyone could help me out it would be much appreciated. I have been trying to use the do while ...=350 but I can't seem to get anything to work. Thanks~ |
Do While Problem
iLastRow = Cells(Rows.Count,"A").End(xlUp).Row For i = iLastRow To 2 Step -1 If Cells(i,"C").Value = 350 Then Rows(i).Cells.ClearContents End If Next i -- --- HTH Bob (change the xxxx to gmail if mailing direct) "Bongard" wrote in message ups.com... I am trying to figure out how to write a macro that will delete all information in a row for columns A through O, if the current value of column c in that row = 350. I would post some of the code I have tried but it is a huge mess. I feel like this should be pretty simple. If anyone could help me out it would be much appreciated. I have been trying to use the do while ...=350 but I can't seem to get anything to work. Thanks~ |
Do While Problem
As always, please do post your code so we can see that you are trying.
-- Don Guillett SalesAid Software "Bongard" wrote in message ups.com... I am trying to figure out how to write a macro that will delete all information in a row for columns A through O, if the current value of column c in that row = 350. I would post some of the code I have tried but it is a huge mess. I feel like this should be pretty simple. If anyone could help me out it would be much appreciated. I have been trying to use the do while ...=350 but I can't seem to get anything to work. Thanks~ |
Do While Problem
Bob thank you for your reply. Is there any way I can do this with a do
while statement? I have to do this about 10 different times in the spreadsheet so I thought it would be easiest to do one simple do while statment for each range. Thanks, |
Do While Problem
Sub RecalcReportTrial() Sheets("FASB91RecalcReport").Select Dim rng As Excel.Range For Each rng In Worksheets("FASB91RecalcReport").Range("c5:c20") If rng.Value = 350 Then rng.ClearContents 'ActiveCell.Offset(0, 2).Select End If Next This is what I am currently trying. The problem is that I can only delete the rng, and not any other cells. I would also like to use a do while statment. Thanks for your help! |
Do While Problem
Use Bob's or datafilterautofilter on col c for 350clear. Record a macro if desired. -- Don Guillett SalesAid Software "Bongard" wrote in message s.com... Sub RecalcReportTrial() Sheets("FASB91RecalcReport").Select Dim rng As Excel.Range For Each rng In Worksheets("FASB91RecalcReport").Range("c5:c20") If rng.Value = 350 Then rng.ClearContents 'ActiveCell.Offset(0, 2).Select End If Next This is what I am currently trying. The problem is that I can only delete the rng, and not any other cells. I would also like to use a do while statment. Thanks for your help! |
Do While Problem
I can try and work with Bob's but it clears the contents in more than
columns a through 0. the macro must not delete anything further than column 0 because I have formulas that must be preserved. How would I stop Bob's formula from deleting that needed data? Sub trial() iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 2 Step -1 If Cells(i, "C").Value = 350 Then Rows(i).Cells.ClearContents End If Next i End Sub Once this is done for the first block I must then use a reference to get down to the next block of data and do the same thing with the value 501. Thanks for your help guys, Brian |
Do While Problem
Sub trial()
i = 2 Do While Cells(i,"C").Value < "" If Cells(i, "C").Value = 350 Then Cells(i,"C").Resize(,13).ClearContents End If i = i + 1 Loop End Sub But the other technique can be repeated throughout just as a Do Loop can. The advantage of a For ... Next loop is that the index is maintained by the loop. -- --- HTH Bob (change the xxxx to gmail if mailing direct) "Bongard" wrote in message ups.com... I can try and work with Bob's but it clears the contents in more than columns a through 0. the macro must not delete anything further than column 0 because I have formulas that must be preserved. How would I stop Bob's formula from deleting that needed data? Sub trial() iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 2 Step -1 If Cells(i, "C").Value = 350 Then Rows(i).Cells.ClearContents End If Next i End Sub Once this is done for the first block I must then use a reference to get down to the next block of data and do the same thing with the value 501. Thanks for your help guys, Brian |
Do While Problem
But the other technique can be repeated throughout just as a Do Loop can. The advantage of a For ... Next loop is that the index is maintained by the loop. Bob thank you for your reply. I pasted the code into VB but when I tried to run the subroutine nothing happened. I actually got the other code to work so that will suffice for now. However can you explain what you meant when you explained the advantage of a ForNext loop? what index would be maintained? and how do these two funcctions differ? Thanks guys! -Brian |
Do While Problem
But the other technique can be repeated throughout just as a Do Loop can. The advantage of a For ... Next loop is that the index is maintained by the loop. Bob thank you for your reply. I pasted the code into VB but when I tried to run the subroutine nothing happened. I actually got the other code to work so that will suffice for now. However can you explain what you meant when you explained the advantage of a ForNext loop? what index would be maintained? and how do these two funcctions differ? Thanks guys! -Brian |
Do While Problem
In your Do ... Loop, you were using the variable i was controlling the loop.
The code has to initialise the index, increment it (i = i + 1), and so on, but the For i = 1 To Limit .... Next i manages it all for you. -- --- HTH Bob (change the xxxx to gmail if mailing direct) "Bongard" wrote in message oups.com... But the other technique can be repeated throughout just as a Do Loop can. The advantage of a For ... Next loop is that the index is maintained by the loop. Bob thank you for your reply. I pasted the code into VB but when I tried to run the subroutine nothing happened. I actually got the other code to work so that will suffice for now. However can you explain what you meant when you explained the advantage of a ForNext loop? what index would be maintained? and how do these two funcctions differ? Thanks guys! -Brian |
All times are GMT +1. The time now is 08:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com