Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 22nd, 2012, 07:53 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
ws.Columns(ColCtr).Delete
ColCtr = ColCtr - 1
End If
Next
Next
End Sub
Reply With Quote
  #2 (permalink)  
Old July 29th, 2012, 10:08 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Here is a hint:

Code:
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

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

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:30 PM.


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