Code: Select all
.Parent.Close False
Code: Select all
.Parent.Close False
Code: Select all
ThisWorkbook.Save
Code: Select all
Sub test()
Dim fn As String, a, r As Range, x, BK As String, myVal
fn = "C:\Users\**I've been banned**\Desktop\1.xls"
With Workbooks.Open(fn).Worksheets.Item(1)
a = .Cells(1).CurrentRegion.Columns("i").Value
.Parent.Close False
End With
With Worksheets.Item(1)
For Each r In .Range("b2", .Range("b" & Rows.Count).End(xlUp))
myVal = r.Value
If Not IsNumeric(myVal) Then myVal = Chr(34) & myVal & Chr(34)
x = Application.Match(r.Value, a, 0)
If IsNumeric(x) Then
With .Cells(r.Row, Columns.Count).End(xlToLeft)
' *** CHANGED ***
If .Column = 2 Then
' If we don't have a value yet, use 1
.Cells(1, 2) = 1
Else
' Otherwise, increase by 1
.Cells(1, 2) = .Value + 1
End If
' *** END OF CHANGE ***
End With
End If
Next
End With
ThisWorkbook.Save
End Sub