Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, Does anyone know how to have a macro in Excell insert a new colum automatically? Also, if i was comparing dates in two columns, how could i have i automatically enter the difference in the column newly created? Thanks, Chri -- Altec10 ----------------------------------------------------------------------- Altec101's Profile: http://www.excelforum.com/member.php...fo&userid=3453 View this thread: http://www.excelforum.com/showthread.php?threadid=54300 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Yes, you can insert a column automatically and have it enter th difference b/t two dates. What events will trigger the macro to inser a column and enter the difference? Altec101 Wrote: Hello, Does anyone know how to have a macro in Excell insert a new colum automatically? Also, if i was comparing dates in two columns, how could i have i automatically enter the difference in the column newly created? Thanks, Chri -- Ikaabo ----------------------------------------------------------------------- Ikaabod's Profile: http://www.excelforum.com/member.php...fo&userid=3337 View this thread: http://www.excelforum.com/showthread.php?threadid=54300 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I would like to have it insert the column and data when the macro is run manually. -- Altec101 ------------------------------------------------------------------------ Altec101's Profile: http://www.excelforum.com/member.php...o&userid=34539 View this thread: http://www.excelforum.com/showthread...hreadid=543007 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Here's an example of how you might go about it, tho obviously your ranges will likely differ: Sub MyMacro() Range("C:C").EntireColumn.Insert With Range("C1") ..Value = "=(B1-A1)" ..NumberFormat = "General" End With End Sub Then you can create a macro button to Call MyMacro when pressed. Altec101 Wrote: I would like to have it insert the column and data when the macro is run manually. -- Ikaabod ------------------------------------------------------------------------ Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371 View this thread: http://www.excelforum.com/showthread...hreadid=543007 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks for the reply. If i had 2 columns of data with multiple rows (say 50 rows - the amount of rows will be different each time) and wanted to get a date difference between column C and D and have it automatically input the difference into column E, is there a way I can do that ? -- Altec101 ------------------------------------------------------------------------ Altec101's Profile: http://www.excelforum.com/member.php...o&userid=34539 View this thread: http://www.excelforum.com/showthread...hreadid=543007 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Give this a go Sub MyMacro() Dim i As Integer i = 0 Range("E:E").EntireColumn.Insert Range("E1").Select Do If IsEmpty(ActiveCell.Offset(i, -1)) = False Then ActiveCell.Offset(i, 0).Value = "=(D1-C1)" i = i + 1 End If Loop Until IsEmpty(ActiveCell.Offset(i, -1)) Range("E:E").NumberFormat = "General" End Sub Altec101 Wrote: Thanks for the reply. If i had 2 columns of data with multiple rows (say 50 rows - the amount of rows will be different each time) and wanted to get a date difference between column C and D and have it automatically input the difference into column E, is there a way I can do that ? -- Ikaabod ------------------------------------------------------------------------ Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371 View this thread: http://www.excelforum.com/showthread...hreadid=543007 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Let's try this then... Sub MyMacro() Dim i As Integer i = 0 Range("E:E").EntireColumn.Insert Range("E1").Select Do If IsEmpty(ActiveCell.Offset(i, -1)) = False Then ActiveCell.Offset(i, 0).FormulaR1C1 = "=(rc[-1]-rC[-2])" i = i + 1 End If Loop Until IsEmpty(ActiveCell.Offset(i, -1)) Range("E:E").NumberFormat = "General" End Sub Altec101 Wrote: Thanks for the reply. If i had 2 columns of data with multiple rows (say 50 rows - the amount of rows will be different each time) and wanted to get a date difference between column C and D and have it automatically input the difference into column E, is there a way I can do that ? -- Ikaabod ------------------------------------------------------------------------ Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371 View this thread: http://www.excelforum.com/showthread...hreadid=543007 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Insert Column with macro | Excel Discussion (Misc queries) | |||
Macro- Column Insert | Excel Discussion (Misc queries) | |||
Macro - Insert&Label Column, if the labeled column doesn't exist | Excel Programming | |||
Need Macro to Find Column Heading -- if none, then insert new column | Excel Programming | |||
Macro to insert column | Excel Programming |