Adding rows based on Users selection [Closed]

Report
-
Posts
2675
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 5, 2020
-
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 reply

Posts
2675
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 5, 2020
448
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

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!