AndrewGKenneth
Board Regular
- Joined
- Aug 6, 2018
- Messages
- 59
Hi there,
I am having a problem with my current bit of code as I am quite new to vba. The code I am having an issue with is shown below.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range ("J3").Value > 0 and Range ("C3").Value = "" Then
Range ("C3").Value = Range("C2").Value
Range ("D3").Value = Range("D2").Value
Range ("E3").Value = Range("E2").Value
Range ("F3").Value = Range("F2").Value
Range ("G3").Value = Range("G2").Value
Range ("H3").Value = Range("H2").Value
Range ("I3").Value = Range("I2").Value
End IF
If Range ("J4").Value > 0 and Range ("C4").Value = "" Then
Range ("C4").Value = Range("C3").Value
Range ("D4").Value = Range("D3").Value
Range ("E4").Value = Range("E3").Value
Range ("F4").Value = Range("F3").Value
Range ("G4").Value = Range("G3").Value
Range ("H4").Value = Range("H3").Value
Range ("I4").Value = Range("I3").Value
End if
And so on ........
I need this to continue all the way down the worksheet but don't currently know how to loop this function. At the moment, I have manually entered the code all the way down to row 150. But have now had the error message Compile Error: Procedure to Large.
Could someone please help me how to code this function to loop using the for next function please?
Thanks so much in advance,
Andrew
I am having a problem with my current bit of code as I am quite new to vba. The code I am having an issue with is shown below.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range ("J3").Value > 0 and Range ("C3").Value = "" Then
Range ("C3").Value = Range("C2").Value
Range ("D3").Value = Range("D2").Value
Range ("E3").Value = Range("E2").Value
Range ("F3").Value = Range("F2").Value
Range ("G3").Value = Range("G2").Value
Range ("H3").Value = Range("H2").Value
Range ("I3").Value = Range("I2").Value
End IF
If Range ("J4").Value > 0 and Range ("C4").Value = "" Then
Range ("C4").Value = Range("C3").Value
Range ("D4").Value = Range("D3").Value
Range ("E4").Value = Range("E3").Value
Range ("F4").Value = Range("F3").Value
Range ("G4").Value = Range("G3").Value
Range ("H4").Value = Range("H3").Value
Range ("I4").Value = Range("I3").Value
End if
And so on ........
I need this to continue all the way down the worksheet but don't currently know how to loop this function. At the moment, I have manually entered the code all the way down to row 150. But have now had the error message Compile Error: Procedure to Large.
Could someone please help me how to code this function to loop using the for next function please?
Thanks so much in advance,
Andrew
Last edited: