Hi All,
Need a bit of help with my VBA formula.
Trying to copy and paste a cell from Sheet 2 or 3 depending on the value of a cell from sheet 1. Please see code below:
So depending on what I select, either Sheet 2 or Sheet 3, I need it to go to the relevant sheet and copy the very last number of that sheet and copy into Sheet 1 Cell B2. I can get it to do everything else apart from the pasting. When I have tried with this, it crashes and continuously loops. How do I break the loop and make it do it just the one time until I select the other sheet?
Please could someone help. I have tried loads of different ways but it always crashes and is continuously looping itself.
Thanks For your Help.
Need a bit of help with my VBA formula.
Trying to copy and paste a cell from Sheet 2 or 3 depending on the value of a cell from sheet 1. Please see code below:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B6").Value = "Sheet2" Then
Sheets("Sheet2").Select
ActiveCell.SpecialCells(xlLastCell).Select
Selection.Copy
Worksheets("Sheet1").Select
Range("B2").Select
Selection.Paste
Sheets("IndiCater").Select
Application.CutCopyMode = False
ActiveSheet.Range("A1").Select
Sheets("Sheet1").Select
ElseIf Range("B6").Value = "Sheet3" Then
Sheets("Sheet3").Select
ActiveCell.SpecialCells(xlLastCell).SelectSelection.Copy
Worksheets("Sheet1").Select
Range("B2").Select
Selection.Paste
Sheets("IndiCater").Select
Application.CutCopyMode = False
ActiveSheet.Range("A1").Select
Sheets("Sheet1").Select
End If
End Sub
So depending on what I select, either Sheet 2 or Sheet 3, I need it to go to the relevant sheet and copy the very last number of that sheet and copy into Sheet 1 Cell B2. I can get it to do everything else apart from the pasting. When I have tried with this, it crashes and continuously loops. How do I break the loop and make it do it just the one time until I select the other sheet?
Please could someone help. I have tried loads of different ways but it always crashes and is continuously looping itself.
Thanks For your Help.