Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ramana
Public Sub Insert_Col() Dim Sht As Worksheet For Each Sht In Worksheets Sht.Range("F1").EntireColumn.Insert Next End Sub Is this what you are after? Ken Johnson |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Ramana,
Sorry, I left out the bit about column width! How about: Public Sub Insert_Col() Dim Sht As Worksheet For Each Sht In Worksheets With Sht.Range("F1") ..EntireColumn.Insert ..Offset(0, -1).ColumnWidth = 12 End With Next End Sub This makes the column width = 12, change according to your needs. Ken Johnson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi yet again Ramana,
If you only want certain sheets to get the extra column between E&F then this example adds the column to only the 2nd, 3rd, 4th and 5th sheets, determined by the k values in the If statement: Public Sub Insert_Col() Dim Sht As Worksheet, k As Byte For Each Sht In Worksheets k = k + 1 If k = 2 And k <= 5 Then With Sht.Range("F1") ..EntireColumn.Insert ..Offset(0, -1).ColumnWidth = 12 End With End If Next End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Ken, thanks for the reply. While running the code it is giving me runtime error at this line. With sht.Range("f1").EntireColumn.Insert.Offset(0, -1).ColumnWidth = 12 It saying "object" required Pl. can you have a look into this. Thanks and Regards Ramana -- ram117 ------------------------------------------------------------------------ ram117's Profile: http://www.excelforum.com/member.php...o&userid=27826 View this thread: http://www.excelforum.com/showthread...hreadid=490098 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Ramana,
that is actually three separate lines of code: With Sht.Range("F1") ..EntireColumn.Insert ..Offset(0,-1).ColumnWidth = 12 End With Make sure you start a new line at .EntireColumn....... then another new line at .Offset etc I ran the code on my PC and it worked fine. Let me know how you go. Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to Inserting Columns and then add column to horizontal total | Excel Discussion (Misc queries) | |||
Inserting columns | Excel Discussion (Misc queries) | |||
Inserting new columns past the last column | Excel Discussion (Misc queries) | |||
inserting new columns | Excel Discussion (Misc queries) | |||
Inserting columns into a row | Excel Discussion (Misc queries) |