help me to look the following code

  • Thread starter Thread starter LEibo
  • Start date Start date
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
 
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
 
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
 
Back
Top