Auto generating a table based on a single number...

Michelle71

New Member
Joined
Jun 19, 2019
Messages
1
I am looking to auto-generate a table containing a variable number of columns with each column containing the same values...

For example, if I have a single column with values:

System 1
40
40
60
80
120
160
40
40

And I enter the number of systems: Systems = 10...

Is there a way to create a table with ten columns containing the values above? Is there a way to increment the header to say "System 2," "System 3," etc.?

Thanks for your help.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
A lot of people use the term Table when actually they mean a sheet.

This script will look down column(A) of the active sheet and copy all the data so Column(A) values will now be copied to Columns(B) and Columns (C) and so on determined by the number you enter into the Inputbox

So if you enter 5 into the Inputbox columns A B C D and E will all have the same Data

Now if your actually referring to a Excel Table which is a Range on a Excel sheet then I would need to know the name of the Table

This script assumes you have Data in Column(A) of the active sheet.

Code:
Sub Insert_Table()
'Modified  6/20/2019  1:49:49 AM  EDT
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim ans As Long
ans = InputBox("Enter How many systems")
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(2, 1).Resize(Lastrow).Copy
Cells(2, 2).Resize(Lastrow, ans - 1).PasteSpecial xlValues
Application.CutCopyMode = False
For i = 1 To ans
    Cells(1, i).Value = "System " & i
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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