#1
|
|||
|
|||
Code for column button?
Hi I am new to excel programming 2013 and was hoping if someone can help me. I am trying to add 1 blank column to a spreadsheet based on the user input after they click this button that is an activex control. The column will end based on how many rows there are in my table, meaning if there are 10 rows I should not see a column on line 11 of the spreadsheet. Also here is what I have so far, please check below. My issue is that it generates the column that I want, but it does so for the whole spreadheet and I only want it to generate a column until the last row of my table?
HELP? Private Sub CommandButton2_Click() Dim x As Variant Dim ColumnNum x = InputBox("Enter a column that you want to add: ", "What column?") If x = "" Then Exit Sub ColumnNum = x ThisWorkbook.Sheets("Sheet1").Columns(ColumnNum).I nsert shift:=xlRight ThisWorkbook.Sheets("Sheet1").Columns(ColumnNum).C learContents End Sub Last edited by cloudforgiven; 12-14-2016 at 08:37 AM. |
#2
|
|||
|
|||
Perhaps one of these sites will be of assistance for dealing with your table.
https://www.thespreadsheetguru.com/b...t-excel-tables http://www.jkp-ads.com/articles/Exce...lComments=True |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sorting a table by column using a button | lozza | Word VBA | 0 | 10-27-2016 07:37 AM |
How to copy format of a column using spin button | Tyberian1988 | Excel Programming | 2 | 03-10-2014 10:09 PM |
VBA code to fix column widths | molesy | Excel | 3 | 09-16-2013 12:51 PM |
VBA Code for a SUBMIT button in a Word form | BlueMax | Word VBA | 3 | 08-07-2013 06:26 AM |
VBA code for count w and write into another column in excel | tomlam | Excel Programming | 2 | 10-09-2012 03:56 AM |