Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Chris
 
Posts: n/a
Default Dynamic column insert (macro)

Hi

I have a table and I wish to create a macro to add a column to my "table".
However if i use the insert function it isn't dynamic and would always
insert in the same column. I have set out below a rough idea of what I would
like.

ie.

Column A B C D

Macro (Run once)

Column A B C D E

Macro (Run Twice)

Column A B C D E F

Right now if I run my macro twice i get the follwing.

Column A B C D F E

I think the key is for a macro to recognise a cell and then being able to
select the whole column to which that cell belongs.



Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
Ardus Petus
 
Posts: n/a
Default Dynamic column insert (macro)

Could you please post some sample data?

Cheers,
--
AP

"Chris" a écrit dans le message de
...
Hi

I have a table and I wish to create a macro to add a column to my "table".
However if i use the insert function it isn't dynamic and would always
insert in the same column. I have set out below a rough idea of what I

would
like.

ie.

Column A B C D

Macro (Run once)

Column A B C D E

Macro (Run Twice)

Column A B C D E F

Right now if I run my macro twice i get the follwing.

Column A B C D F E

I think the key is for a macro to recognise a cell and then being able to
select the whole column to which that cell belongs.



Thanks



  #3   Report Post  
Posted to microsoft.public.excel.misc
davesexcel
 
Posts: n/a
Default Dynamic column insert (macro)


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True 'Eliminate Edit status due to doubleclick
Target.Offset(1).EntireColumn.Insert
Target.EntireColumn.Copy Target.Offset(1).EntireColumn
On Error Resume Next
Target.Offset(1).EntireRow.SpecialCells(xlConstant s).ClearContents
On Error GoTo 0
End Sub

Here's a Worksheet macro, you will need to place it in a worksheet
module, of course it doesn't have to be a double click event, you can
move it to a button. You can also modify it to find the last column as
well


--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=522562

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find text string in a column and paste data in another nicolascap Excel Discussion (Misc queries) 8 March 14th 06 03:13 PM
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
Macro to open workbook and copy and paste values in to orig workbo Dena X Excel Worksheet Functions 1 December 15th 05 11:13 PM
Macro to change Chart Range when inserting a column Mark Charts and Charting in Excel 1 September 13th 05 01:12 PM
Return Count for LAST NonBlank Cell in each Row Sam via OfficeKB.com Excel Worksheet Functions 12 April 17th 05 10:36 PM


All times are GMT +1. The time now is 09:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"