Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2003, 05:10 PM
Authorized User
 
Join Date: Nov 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default add column in excel with VBA

Hi,

   I would like know how can i add column between others columns with VBA , exemple when someone click on a button.

        thanks you



 
Old November 19th, 2003, 07:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try something like this:

Code:
Sub Test()
Dim x as string

x = InputBox("Enter the column you need inserting, eg "a")

Workbooks("yourworkbook").worksheets("theworksheet").Columns(x).Insert

End Sub
Create your button, link its code to this sub, and you're away. Obviously, you will need to alter the names to suit application, and you will need some way of ensuring that the input is valid, but this is left as an exercise for the reader ;)

HTH


There are two secrets to success in this world:
1. Never tell everything you know
 
Old November 19th, 2003, 09:37 AM
Authorized User
 
Join Date: Nov 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you very much for the solution...








Similar Threads
Thread Thread Starter Forum Replies Last Post
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Add 1 to next column deontae45 SQL Language 2 December 18th, 2006 01:42 PM
Add and Refresh Excel QueryTable from VBA DaveJoyG Excel VBA 2 September 28th, 2006 07:23 AM
Excel/VBA Multi-Column Lookup - Round 2 RollingWoodFarm Excel VBA 4 August 3rd, 2006 07:28 PM
Excel VBA to SQL & back to VBA edesousa Excel VBA 1 June 1st, 2004 02:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.