Hi All
Have a complicated sheet that does things on the fly as the user changes fields and enters data etc etc.
To do this I use: Private Sub Worksheet_SelectionChange(ByVal Target As Range) on Sheets(1)
Which as you know runs the code whenever the selection changes on the sheet, which is great.
My issue is that I have this code within the SelectionChange sub:
There is massively more code within the With block but that is the relevant part.
What happens is when the ".Range("D" & i).PasteSpecial xlPasteValues" line is run, the code takes that as a selectionchange, and then the whole selectionchange code runs again from the start.
Which is screwing up the rest of the code below ".Range("D" & i).PasteSpecial xlPasteValues"
Any ideas on how to get around this?
Regards
Have a complicated sheet that does things on the fly as the user changes fields and enters data etc etc.
To do this I use: Private Sub Worksheet_SelectionChange(ByVal Target As Range) on Sheets(1)
Which as you know runs the code whenever the selection changes on the sheet, which is great.
My issue is that I have this code within the SelectionChange sub:
Code:
With Thisworkbook.Sheets(1)
Lastrow = ThisWorkbook.Sheets(2).Range("A" & ThisWorkbook.Sheets(2).Rows.Count).End(xlUp).Row
ThisWorkbook.Sheets(2).Range("C" & Lastrow & ":G" & Lastrow).Copy
.Range("D" & i).PasteSpecial xlPasteValues
End With
There is massively more code within the With block but that is the relevant part.
What happens is when the ".Range("D" & i).PasteSpecial xlPasteValues" line is run, the code takes that as a selectionchange, and then the whole selectionchange code runs again from the start.
Which is screwing up the rest of the code below ".Range("D" & i).PasteSpecial xlPasteValues"
Any ideas on how to get around this?
Regards