Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2016, 08:15 PM
cloudforgiven cloudforgiven is offline Code for column button? Windows XP Code for column button? Office 2013
Novice
Code for column button?
 
Join Date: Nov 2016
Posts: 13
cloudforgiven is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 12-18-2016, 07:42 AM
NoSparks NoSparks is offline Code for column button? Windows 7 64bit Code for column button? Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

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
Reply With Quote
Reply



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
Code for column button? VBA code to fix column widths molesy Excel 3 09-16-2013 12:51 PM
Code for column button? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft