Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7195

Why does Excel crash on Worksheet_Change event that changes the worksheet?

$
0
0
Private Sub Worksheet_Change(ByVal Target As Range)Dim lrow1 As LongDim lrow2 As LongDim cell As RangeDim sell As Rangelrow1 = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Rowlrow2 = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).RowFor Each cell In Sheets("Sheet2").Range("A1:A"& lrow2)    For Each sell In Sheets("Sheet1").Range("A1:A"& lrow1)        If cell.Value = sell.Value Then            cell.Offset(0, 1).Value = sell.Offset(0, 1).Value        End If    Next sellNext cellEnd Sub

The first entry works, brings the info correctly. With the second entry Excel crashes.


Viewing all articles
Browse latest Browse all 7195

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>