jordanburch
Active Member
- Joined
- Jun 10, 2016
- Messages
- 443
- Office Version
- 2016
Hey all,
I have the below. I just cant get it to read right. I am not sure how to stop getting the Else without if error. Please see below. Any help is appreciated!
Jordan
I have the below. I just cant get it to read right. I am not sure how to stop getting the Else without if error. Please see below. Any help is appreciated!
Jordan
VBA Code:
If ThisWorkbook.Worksheets("variables").Range("a11").Value = "October" Then
filepath3 = "K:\SHARED\TRANSFER\Enterprise Wide Suspense Initiative\Source Files\97 Field Details\" & ThisWorkbook.Worksheets("Variables").Range("A4").Value & "\" & Left(ThisWorkbook.Worksheets("Variables").Range("A9").Value, 2) & "-" & Mid(ThisWorkbook.Worksheets("Variables").Range("A9").Value, 6, 3) & Right(ThisWorkbook.Worksheets("variables").Range("A9").Value, 2) & "\Field Detail Lines\"
myfile3 = "CO097*.xlsx"
erow = wb1.Sheets("CO SAR").Cells(Rows.Count, 14).End(xlUp).Offset(1, 0).Row
Set wb2 = Workbooks.Open(filepath & myfile)
Dim ws As Worksheet
Dim ClearedSheet As String
ClearedSheet = ""
For Each ws In ActiveWorkbook.Worksheets
If InStr(1, ws.Name, "Detail", vbTextCompare) Then
ClearedSheet = ws.Name
End If
Next
ShtName1 = ClearedSheet
With wb2
Sheets(ClearedSheet).Select
With ActiveSheet
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
Else
If .FilterMode Then
.ShowAllData
End If
End If
End With
Dim ShtName As String
ShtName = Sheets(ClearedSheet).Name
If Evaluate("isref('" & ShtName & "'!A1)") Then
'sheet exists do something
Else
'sheet doesn't exist do something else
End If
If Evaluate("isref('" & ShtName1 & "'!A1)") Then
wb2.Sheets(ClearedSheet).Range("q2:q25000").Value = wb2.Name
.Sheets(ClearedSheet).Range("c2:q25000").Copy Destination:=wb1.Worksheets("CO SAR").Cells(erow, 1)
.Close savechanges:=False
ElseIf Evaluate("isref('" & ShtName3 & "'!A1)") Then
.Sheets(ClearedSheet).Range("c2:p25000").Copy Destination:=wb1.Worksheets("CO SAR").Cells(erow, 1)
.Close savechanges:=False
ElseIf Evaluate("isref('" & ShtName2 & "'!A1)") Then
.Sheets(ClearedSheet).Range("c2:p25000").Copy Destination:=wb1.Worksheets("CO SAR").Cells(erow, 1)
.Close savechanges:=False
End If
End With
End If
Else