amitcohen
Board Regular
- Joined
- Jan 14, 2010
- Messages
- 118
Hi Guys
I'm using the following code to start a little macro that when clicking on a cell, it will populate the value in another cell.
The problem I'm facing is that I need over 1200 cells with this code (it's divided to 3 columns, 400 cells in a column)
And while creating a code for each and every cell, Excel giving me an error, saying the code is to large to execute.
Is there a way to improve the code, so I can use it on a large scale?
Here is the code:
This code needed for Columns N, O, P.
400 cells each. ("N1:N400") etc'
Thank you in advance for your kind help
Amit
I'm using the following code to start a little macro that when clicking on a cell, it will populate the value in another cell.
The problem I'm facing is that I need over 1200 cells with this code (it's divided to 3 columns, 400 cells in a column)
And while creating a code for each and every cell, Excel giving me an error, saying the code is to large to execute.
Is there a way to improve the code, so I can use it on a large scale?
Here is the code:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' N Column
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N1")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N1")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N2")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N2")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N3")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N3")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N4")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N4")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N5")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N5")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N6")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N6")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N7")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N7")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N8")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N8")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N9")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N9")
End If
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("N10")) Is Nothing Then
Range("L2").Select
ActiveCell.FormulaR1C1 = Range("N10")
End If
End Sub
400 cells each. ("N1:N400") etc'
Thank you in advance for your kind help

Amit