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 July 22nd, 2012, 07:53 AM
Registered User
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Excel 2003 - Need Macro for Insert Column in excel

Hi All,

I am using Excel Version 2003

I have macro already and addition to that i need to add one more command or run macro that insert column and name that column as "Month" in every sheet of an excel.

I have header row i want to insert the column after the header name Volume

Can any one help in this

Thanks in advance

This my macro

Sub DelColumnNotInList()
Dim LastCol As Double
Dim ColCtr As Double
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
LastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
For ColCtr = 1 To LastCol
If InStr("Word Pay Cost Volume Rank Type", ws.Cells(1, ColCtr).Text) = 0 Then
ColCtr = ColCtr - 1
End If
End Sub
Old July 29th, 2012, 10:08 PM
Friend of Wrox
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts


Here is a hint:

Dim rFndResult As Range
Set rFndResult = Range("A1:AZ1").Find("Volume", , xlValues, xlWhole)
If Not rFndResult Is Nothing Then
    MsgBox rFndResult.Column
    Columns(rFndResult.Column + 1).Insert
    Cells(1, rFndResult.Column + 1).Value = "Month"
End If

C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Excel 2000 and Excel 2003 DanRoche C# 2 March 4th, 2010 05:10 AM
#NAME? error running Excel 2003 VBA in Excel 2007 steveburn Excel VBA 0 October 24th, 2009 08:47 AM
Help! Conversion Excel 2003 VBA codes to Excel 2007 sunny76 BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 August 13th, 2009 05:38 AM
Excel Macro works in 2000 but not 2003 BUCKLSU Excel VBA 1 June 5th, 2007 01:40 PM
Excel 2000 vs Excel 2002 Macro Issue williadn Excel VBA 1 July 14th, 2005 09:09 AM

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