Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert a column with it's own delete button?


Good Morning,
I have a routine for inserting a copy of another column. The sheet wil
eventually need to be protected before others in my office can use it
so what I would like to do is to create a delete command button "tied
to the newly created column, so people can add and delete columns a
they need to. But, I have never created a control with code and I nee
some help. If its possible, the button should be placed in the 5th ro
of the column.

Here is my column create code:

Option Explicit

Sub AddMatnonPercent()
Dim MatNON As Range
Dim SCol As Integer
SCol = Range("MatNON").Column + 1
Range("MatNON").Copy
Columns(SCol).Select
Selection.Insert Shift:=xlToRight
Cells(7, SCol).ClearContents
Cells(7, SCol).Select
Application.CutCopyMode = False
End Su

--
Case

-----------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...nfo&userid=454
View this thread: http://www.excelforum.com/showthread.php?threadid=54371

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Insert a column with it's own delete button?

Sub AddMatnonPercent()
Dim MatNON As Range
Dim SCol As Integer
Dim btn As Button
SCol = Range("MatNON").Column + 1
Range("MatNON").Copy
Columns(SCol).Select
Selection.Insert Shift:=xlToRight
Cells(7, SCol).ClearContents
Cells(7, SCol).Select
Application.CutCopyMode = False
With Cells(1, SCol)
Set btn = ActiveSheet.Buttons.Add(Left:=.Left, _
Top:=.Top, Width:=.Width, Height:=.Height)
End With
btn.Caption = "Delete me"
btn.OnAction = "Btn_Click"
End Sub

Sub Btn_click()
Dim sName As String
Dim btn As Button
sName = Application.Caller
Set btn = ActiveSheet.Buttons(sName)
btn.TopLeftCell.EntireColumn.Delete
btn.Delete
End Sub

--
Regards,
Tom Ogilvy


"Casey" wrote:


Good Morning,
I have a routine for inserting a copy of another column. The sheet will
eventually need to be protected before others in my office can use it,
so what I would like to do is to create a delete command button "tied"
to the newly created column, so people can add and delete columns as
they need to. But, I have never created a control with code and I need
some help. If its possible, the button should be placed in the 5th row
of the column.

Here is my column create code:

Option Explicit

Sub AddMatnonPercent()
Dim MatNON As Range
Dim SCol As Integer
SCol = Range("MatNON").Column + 1
Range("MatNON").Copy
Columns(SCol).Select
Selection.Insert Shift:=xlToRight
Cells(7, SCol).ClearContents
Cells(7, SCol).Select
Application.CutCopyMode = False
End Sub


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=543714


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert a column with it's own delete button?


Tom,
Brilliant! Exactly what I needed. Thank you so much for the help

--
Case

-----------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...nfo&userid=454
View this thread: http://www.excelforum.com/showthread.php?threadid=54371

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
Detect Delete Column/Row vs Insert Otto Moehrbach Excel Programming 0 April 20th 06 02:08 PM
Some 'Names' cannot be deleted by Insert|Name|Define-Delete button David Iacoponi Excel Worksheet Functions 1 October 20th 05 09:03 PM
Deactivating Insert/Delete Row/Column [email protected] Excel Programming 1 September 22nd 04 08:33 PM
Deactivating Insert /Delete Row/Column [email protected] Excel Programming 0 September 22nd 04 04:16 AM
Row/Column Insert/Delete Von Shean Excel Programming 1 January 21st 04 10:09 AM


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

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

About Us

"It's about Microsoft Excel"