VBA coding for the question

vishwajeet_chakravorty

Board Regular
Joined
Mar 8, 2010
Messages
120
Dear Sir, Suppose I write any number (Example 100) in Cell A1, the cells A2 to A12 should be filled with the same number automatically. And again in cell A4 I write any other number, the cell from A5 to A12 should be filled with the same number automatically. How to write a VBA code for this thing to happen?
 
You should be able to see a pattern emerging:

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 15 Then
    Select Case Target.Column
        Case 1, 3, 6
            Application.EnableEvents = False
            Range(Cells(Target.Row + 1, Target.Column), Cells(15, Target.Column)).Value = Target.Value
            Application.EnableEvents = True
    End Select
End If
End Sub

Sir, This is working from A1 to A15 But I want from A5 to A15,C5 to C15 and E5 to E15. I want to see the whole pattern to learn.
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
This is not difficult

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 5 Then
    Select Case Target.Column
        Case 1, 3, 5
            Application.EnableEvents = False
            Range(Cells(Target.Row + 1, Target.Column), Cells(15, Target.Column)).Value = Target.Value
            Application.EnableEvents = True
    End Select
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top