Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Insert Columns based on cell value

Hello!
Could you please tell me how (in a macro) to insert
multiple blank columns based on the value of a cell.
Example: if A1=2, then insert 2 columns...a new B & C
column. Example: If D1=4, then insert 4 columns...a new
E, F, G & H column.
Your help would really be appreciated.
Thank you,
Jill
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert Columns based on cell value

put the foolwoing code in the worksheet module

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Row = 1 And IsNumeric(Target.Value) Then
If Target.Value 0 Then
Range(Cells(1, Target.Column + 1).Address, Cells(1,
Target.Column + Target.Value).Address).EntireColumn.Insert
End If
End If

End Sub


- Mangesh


---
Message posted from http://www.ExcelForum.com/

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
insert an image based on a cell value brig239 New Users to Excel 1 June 3rd 09 07:10 PM
Insert value based on color of the cell aberdonian user Excel Worksheet Functions 3 December 17th 07 07:47 PM
Insert a value in a cell based upon a comparison of cell values in 2 separate worksheets Doctorjones_md Excel Discussion (Misc queries) 7 June 8th 07 09:32 PM
Insert a value in a cell based upon a comparison of cell values in 2 separate worksheets Doctorjones_md Excel Worksheet Functions 7 June 8th 07 09:32 PM
how do I insert a cell based on its match with an adjacent cell? Gabbon Excel Worksheet Functions 12 January 24th 06 12:28 PM


All times are GMT +1. The time now is 04:40 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"