View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
BluzDude BluzDude is offline
external usenet poster
 
Posts: 5
Default Simple "If" statement ?

I get an error message that says:

Run-time error '438':
Object doesn't support this property or method

Also, the data starts on row 4 on both sheets.

This is what I put in the macro, substituting "Jobs" for "Sheet1" and "Done"
for "Sheet2".

Public Sub CutToDone()
With Worksheets("Jobs")
iLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If .Cells(i, "F").Value < "" Then
.Worksheets("Done").Rows(1).Insert
.Cells(i, "F").Copy .Worksheets("Done").Range("A1")
.Rows(i).Delete
End If
Next i
End With
End Sub

"Bob Phillips" wrote:

Do you want to pick up all of the items in column F? Something like this

With Worksheets("Sheet1")
iLastRow = .Cells(.Rows.Count,"F").End(xlUp).Row
For i = iLastRow to 1 Step -1
If .Cells(i, "F").Value < "" Then
.Worksheets("Sheet2").Rows(1).Insert
.Cells(i, "F").Copy .Worksheets("Sheet2").Range("A1")
.Rows(i).delete
End If
Next i
End With

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"BluzDude" wrote in message
...
Thanks a group Bob!

Now, what I am doing is moving data from one spreadsheet to another
spreadsheet if there is a date in the "F" column, and I can have up to 30
rows of data that might or might not have a date in column "F". I'm doing
a
"cut/insert" operation in order to move completed jobs from a "jobs" sheet
to
a "done" sheet which means that I am deleting each row from the "jobs"
sheet
that gets moved to the "done" sheet. What is happening is that every time
the
macro encounters a row that gets moved, the procedure ends and I have to
run
it again to get to the next one that needs to be moved. I need to re-run
this
macro automatically until it has run it 30 times. Is this possible with a
some kind of counter like a "for...next" statement? If so, could you show
me
how to write it and if I need to do anything else to your original code? I
know this stuff is really simple if you know VB but I don't know much VB.
I'm
pretty good with formulas in Excel but can't get the syntax right in VB.
Thanks for your time, I really appreciate it. I've been messing with this
thing for 4 days now and it's frustrating the heck out of me.

"Bob Phillips" wrote:

If Range("F4").Value < ""Then
'Code if cell "F4" has a date in it
ElseIf Range("F5").Value < ""Then
'Code if cell "F5" has a date in it
END IF



--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"BluzDude" wrote in message
...
Can someone tell me how to write an "IF" statement that looks at a cell
(F4)
and if that cell has a date in it, it executes the code following, if
the
cell is empty it goes to the next "IF" statement and repeats the same
procedure on the next row (F5), etc., etc.?

I've tried this and it doesn't work:

IF NOT Range("F4") IS NOTHING THEN
'Code if cell "F4" has a date in it
ELSEIF NOT Range("F5") IS NOTHING THEN
'Code if cell "F5" has a date in it
END IF