Thread: Need help
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default Need help

I was not sure what x was. Try this:

Sub stantiate()
Dim lr As Long, sh As Worksheet, rng As Range
Set sh = Sheets("Adjustment")
lr = sh.Cells(Rows.Count, 9).End(xlUp).Row
Set rng = sh.Range("I7:I" & lr)
For Each c In rng
If c.value = x Then
sh.Range("A" & c.Row & ":H" & c.Row).ClearContents
End If
Next
End Sub


This modification assumes that the x variable is a value and not a range
object.







"JLeCoure" wrote in message
...
Thanks for the Help

I am getting the following error when I run this

Runtime err 13 Type mismatch see below where the error happens

"JLGWhiz" wrote:

This should do it:

Sub stantiate()
Dim lr As Long, sh As Worksheet, rng As Range
Set sh = Sheets("Adjustment")
lr = sh.Cells(Rows.Count, 9).End(xlUp).Row
Set rng = sh.Range("I7:I" & lr)
For Each c In rng
If c = x Then <--------Here
sh.Range("A" & c.Row & ":H" & c.Row).ClearContents
End If
Next
End Sub




"JLeCoure" wrote in message
...
I am trying to create a macro that looks a cell and if that cell is
"true"
then I want the macro to clear the fields to the left of that cell. I
have
got it to work on a line by line basis but I wan to be able to set this
macro
up to work on any line

Here is the code I have trying to get variables to work in it

If i7 = x Then Worksheets("Adjustment").Range("A7:h7").ClearConte nts



.