Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I got an error trying to run this script I want to delete the first and 3rd
row to make a flat file database sheet. tia, Sub deleteR1R3() Dim LastRow As Range With ActiveSheet Set LastRow = Cells(Rows.Count, "A").End(xlUp).Row If (LastRow = 1) And IsEmpty(Range("A1")) Then Cells(3, "A").EntireRow.Delete Cells(1, "A").EntireRow.Delete End If End With End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Without looking to close the first thing I notice is you declare LastRow to
be a range object but then try to assign a row number to it... Try this... Sub deleteR1R3() Dim LastRow As Long With ActiveSheet LastRow = Cells(Rows.Count, "A").End(xlUp).Row If (LastRow = 1) And IsEmpty(Range("A1")) Then Cells(3, "A").EntireRow.Delete Cells(1, "A").EntireRow.Delete End If End With End Sub -- HTH... Jim Thomlinson "Janis" wrote: I got an error trying to run this script I want to delete the first and 3rd row to make a flat file database sheet. tia, Sub deleteR1R3() Dim LastRow As Range With ActiveSheet Set LastRow = Cells(Rows.Count, "A").End(xlUp).Row If (LastRow = 1) And IsEmpty(Range("A1")) Then Cells(3, "A").EntireRow.Delete Cells(1, "A").EntireRow.Delete End If End With End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, you are right. I see it now.
"Jim Thomlinson" wrote: Without looking to close the first thing I notice is you declare LastRow to be a range object but then try to assign a row number to it... Try this... Sub deleteR1R3() Dim LastRow As Long With ActiveSheet LastRow = Cells(Rows.Count, "A").End(xlUp).Row If (LastRow = 1) And IsEmpty(Range("A1")) Then Cells(3, "A").EntireRow.Delete Cells(1, "A").EntireRow.Delete End If End With End Sub -- HTH... Jim Thomlinson "Janis" wrote: I got an error trying to run this script I want to delete the first and 3rd row to make a flat file database sheet. tia, Sub deleteR1R3() Dim LastRow As Range With ActiveSheet Set LastRow = Cells(Rows.Count, "A").End(xlUp).Row If (LastRow = 1) And IsEmpty(Range("A1")) Then Cells(3, "A").EntireRow.Delete Cells(1, "A").EntireRow.Delete End If End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error '1004' application or object defined error | Excel Programming | |||
xpath error? Runtime Error 13 type mismatch | Excel Discussion (Misc queries) | |||
runtime error: syntax error or access violation | Excel Programming | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Syntax Error Runtime Error '424' Object Required | Excel Programming |