You are here:

Excel/Excel 2010 _ Appear a specific number of columns


Hi Jan,

I have the following:

In sheet1, I have a some questions and one of the questions is How many members are there in a house and their hobbies? For this question there is a dropdown box with values 1 to 10.
In sheet 2, I have ten columns from b2:k12, and each column is named MEMBER 1....10.

I would like to know how to run a macro, when the person selects number 3 from the dropdown, then 3 columns will appear (i.e. MEMBER1, MEMBER2, MEMBER3), and if selected 6 then six columns appear. The person will enter the data and there will be a macro button to save the data and another button to return to questions, making disappear the table columns.  

Many thanks,

Hi Daniel,

Suppose the # of members is entered in a cell named "NumberOfMembers". This macro creates the list of members on Sheet2:

Sub CreateMemberTable()
   Dim lCt As Long
   For lCt = 1 To Worksheets("Sheet1").Range("NumberOfMembers").Value
       Worksheets("Sheet2").Range("A1").Offset(,lCt - 1).Value = "Member " & lCt
End Sub
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Jan Karel Pieterse


Excel and Excel/VBA questions


Excel MVP

Self employed Excel developer

Bachelor in Chemical Engineering

Awards and Honors
Microsoft MVP award since 2002

Past/Present Clients
Shell, Fortis bank, ABN-AMRO bank, Morgan Stanley, ...

©2016 All rights reserved.