![]() |
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 |
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/ |
All times are GMT +1. The time now is 05:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com