Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does | Excel Programming | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming |