Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
.Value 9999 not recognised
I'm using code from an example posted on Ron de Bruin's web site to delete
rows where the contents of column C equals 9999. However, this isn't working which I assume is to do with column C being numeric, I've tried all sorts but to no avail - any pointers welcome. Thanks, Rob .......................... 'Set the first and last row to loop through Firstrow = .UsedRange.Cells(1).Row Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row 'We loop from Lastrow to Firstrow (bottom to top) For Lrow = Lastrow To Firstrow Step -1 'We check the values in the A column in this example With .Cells(Lrow, "A") If Not IsError(.Value) Then If .Value = 9999 Then .EntireRow.Delete End If End With Next Lrow |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
.Value 9999 not recognised
Hi
Your code is checking column A, not column C. Change the "A" to a "C". You also have things like .UsedRange, which suggests you need to wrap your code inside something like With worksheets("mysheet") 'your code End with Apart from that, the code looks fine. regards Paul On Mar 11, 8:41*am, "Rob" wrote: I'm using code from an example posted on Ron de Bruin's web site to delete rows where the contents of column C equals 9999. *However, this isn't working which I assume is to do with column C being numeric, I've tried all sorts but to no avail - any pointers welcome. *Thanks, Rob ......................... *'Set the first and last row to loop through * * * * Firstrow = .UsedRange.Cells(1).Row * * * * Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row * * * * 'We loop from Lastrow to Firstrow (bottom to top) * * * * For Lrow = Lastrow To Firstrow Step -1 * * * * * * 'We check the values in the A column in this example * * * * * * With .Cells(Lrow, "A") * * * * * * * * If Not IsError(.Value) Then * * * * * * * * * * If .Value = 9999 Then .EntireRow..Delete * * * * * * * * End If * * * * * * End With * * * * Next Lrow |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
.Value 9999 not recognised
Sorry, but just sorted. 9999 was in a merged cell with another column!!!!
"Rob" wrote in message ... I'm using code from an example posted on Ron de Bruin's web site to delete rows where the contents of column C equals 9999. However, this isn't working which I assume is to do with column C being numeric, I've tried all sorts but to no avail - any pointers welcome. Thanks, Rob ......................... 'Set the first and last row to loop through Firstrow = .UsedRange.Cells(1).Row Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row 'We loop from Lastrow to Firstrow (bottom to top) For Lrow = Lastrow To Firstrow Step -1 'We check the values in the A column in this example With .Cells(Lrow, "A") If Not IsError(.Value) Then If .Value = 9999 Then .EntireRow.Delete End If End With Next Lrow |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
add time greater than 9999:56 | Excel Worksheet Functions | |||
Find value (31.12.9999) and clear | Excel Programming | |||
Replace first part of SS# with x's (XXXX-XX-9999) | Excel Programming | |||
Name not recognised | Excel Programming | |||
VBA code only working up to 9999 rows | Excel Programming |