![]() |
help me to look the following code
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 |
help me to look the following code
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 -- Rick (MVP - Excel) "LEibo" wrote in message ... 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 |
help me to look the following code
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 "LEibo" wrote: 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 |
All times are GMT +1. The time now is 06:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com