Adding rows based on Users selection

Closed
nitin - Apr 28, 2014 at 02:03 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Apr 29, 2014 at 11:17 AM
Hello,



I want add rows with say Y1,Y2,Y3...Y10 based on what value the user selects from the drop down i.e. Say a user selects 5 then in the other sheets 5 rows are visible with the heading Y1, Y2...Y5

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Apr 29, 2014 at 11:17 AM
Hi Nitin,

Not sure if your question is specific enough, but let's start with the code below and go from there:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer

If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub

Do
    x = x + 1
    Sheets("Sheet2").Cells(x, "A") = "Y" & x
Loop Until x = Target
    
End Sub


Implement code by right-clicking the drop down sheet's tab and selecting View code. Paste the code in the big white field.

Best regards,
Trowa
0