Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Macro to Add Columns in Excel

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 15-10-2009
Member
 
Join Date: Aug 2009
Posts: 25
Macro to Add Columns in Excel
  

I have a Excel spreadsheet to track employee information. I need to add macro in that adds three columns at the end of the first sheet and it must populate the three new columns with formulas on all records in the sheet? Any recommendations and suggestions are appreciated.

Reply With Quote
  #2  
Old 15-10-2009
Member
 
Join Date: May 2008
Posts: 4,827
Re: Macro to Add Columns in Excel

Use this code :
Code:
Sub CalDat()
Dim wC As Worksheet
Dim wT As Worksheet
Dim rU As Range
Dim lRw As Long

Set wC = Sheets("Code")
Set wT = Sheets("T_Write_off")
Set rU = wsTWO.UsedRange
lRowEnd = rUsed.Rows.Count + rUsed.Row - 1
wT.Range("AH1:AJ1").Formula = wC.Range("AH1:AJ1").Formula
wT.Range("AH2:AJ" & lRowEnd).Formula = wC.Range("AH2:AJ2").Formula
wT.Activate
Range("A1").Select
Selection.End(xlToRight).Select
End Sub
Reply With Quote
  #3  
Old 15-10-2009
Member
 
Join Date: Dec 2008
Posts: 371
Re: Macro to Add Columns in Excel

Check this for example :
Code:
Sub addcol()

LasCol = Cells(1, Colu.Count).End(xlToLeft).Column

Colunt = LastCol
Do While Colunt > 1
If Cells(1, Colunt) > Cells(1, ColCount - 1) + 1 Then
Columns(Colunt).Insert
Cells(1, Colunt) = Cells(1, ColCount + 1) - 1
Else
Colunt = Colunt - 1
End If
Loop
Reply With Quote
  #4  
Old 15-10-2009
Member
 
Join Date: May 2008
Posts: 4,338
Re: Macro to Add Columns in Excel

You need another macro to rearrange the position of columns. For eg. in excel there are A, B, C, D ,E1 COLUMNS. (three in your case). Split your screen, use the F8* key and see what you procedure does work in Excel.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Macro to Add Columns in Excel"
Thread Thread Starter Forum Replies Last Post
Excel 2003 Macro doesn't work in Excel 2007 jjaw Windows Software 3 03-01-2014 02:28 PM
How to divide two different columns data in Excel Chini mao Microsoft Project 1 08-01-2012 05:47 PM
How to sort spreadsheet or columns in Excel Kungfu Pandey Windows Software 1 08-01-2012 01:13 PM
How to multiply two columns in Excel Lanka Boy Windows Software 2 08-01-2012 02:06 AM
How to expand and collapse columns in Excel Asaph Windows Software 5 31-08-2010 11:39 PM


All times are GMT +5.5. The time now is 07:16 AM.