ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Else no If (https://www.excelbanter.com/excel-programming/357981-else-no-if.html)

Nicole Seibert

Else no If
 
I am about to Else no If this section of code. I am sure I am doing
something basic wrong here, but no matter how I play with the code it keeps
giving me errors. The logic is: count the rows of data, if that number is
zero skip the next couple of steps.
Any help out there?

Selection.AutoFilter Field:=12, Criteria1:="<"
Dim LC2 As Long
LC2 = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox ("LC2 is " & LC2)
If LC2 = 0 Then GoTo SKIP
Else
Sheets("Estimated - BA Approved").Select
Range("A3").Select
DC2 = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheets("QueryResultsExcel 1 ").Select
Range("A3:R" & LC2).Select
Selection.Copy
Sheets("Estimated - BA Approved").Select
Range("A" & DC2).Select
ActiveSheet.Paste
End If
SKIP:

Nicole Seibert

Else no If
 
Nevermind... I figured it out

"Nicole Seibert" wrote:

I am about to Else no If this section of code. I am sure I am doing
something basic wrong here, but no matter how I play with the code it keeps
giving me errors. The logic is: count the rows of data, if that number is
zero skip the next couple of steps.
Any help out there?

Selection.AutoFilter Field:=12, Criteria1:="<"
Dim LC2 As Long
LC2 = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox ("LC2 is " & LC2)
If LC2 = 0 Then GoTo SKIP
Else
Sheets("Estimated - BA Approved").Select
Range("A3").Select
DC2 = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheets("QueryResultsExcel 1 ").Select
Range("A3:R" & LC2).Select
Selection.Copy
Sheets("Estimated - BA Approved").Select
Range("A" & DC2).Select
ActiveSheet.Paste
End If
SKIP:


Stefi

Else no If
 
Try the true branch in a separate line:

If LC2 = 0 Then

GoTo SKIP
Else
Sheets("Estimated - BA Approved").Select
Range("A3").Select
DC2 = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheets("QueryResultsExcel 1 ").Select
Range("A3:R" & LC2).Select
Selection.Copy
Sheets("Estimated - BA Approved").Select
Range("A" & DC2).Select
ActiveSheet.Paste
End If
SKIP:


Regards,
Stefi



All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com