help me to look the following code

L

LEibo

Public Sub Tester001()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim delRng As Range
Dim LastRow As Long
Dim i As Long
Dim j As Long

Set WB = Workbooks("C:\Documents and Settings\jliu2\My Documents\prominence
decor inc(2009).xls")
Set SH = WB.Sheets("tb") '

LastRow = SH.Cells(Rows.Count)
Set rng = SH.Range("H12:h" & LastRow)

Application.ScreenUpdating = False

For i = 11 To rng.Rows.Count Step 1
SH.Cells(i, 6).Value = SH.Cells(i, 6).Value - SH.Cells(i, 8).Value
SH.Cells(i, 8).deleted
Next i

Application.ScreenUpdating = False

End Sub
 
R

Rick Rothstein

It might help if you told us why you wanted us to look at the code... what
is the problem you are having with it? I did notice one thing in looking at
your code quickly. I think this line...
LastRow = SH.Cells(Rows.Count)

should be this instead....

LastRow = SH.Cells(SH.Rows.Count, "H").End(xlUp).Row
 
S

Sam Wilson

I think "SH.Cells(i, 8).deleted" will give you a problem, try

SH.Cells(i, 8).delete or SH.Cells(i, 8).clear instead

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top