#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 59
Default 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~

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default 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~



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 59
Default 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,

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 59
Default 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!



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 59
Default 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

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default 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



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
have some problem with database baldamenti Excel Discussion (Misc queries) 1 October 13th 05 05:38 PM
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM
Problem With Reference Update Egon Excel Worksheet Functions 17 July 16th 05 05:45 AM
Copy an Drag cell Formula Problem Nat Excel Discussion (Misc queries) 1 June 20th 05 03:24 PM
Freeze Pane problem in shared workbooks JM Excel Discussion (Misc queries) 1 February 1st 05 12:04 AM


All times are GMT +1. The time now is 08:34 AM.

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"