ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting an entire column causes sub to stop (https://www.excelbanter.com/excel-programming/374410-inserting-entire-column-causes-sub-stop.html)

new2Texas

Inserting an entire column causes sub to stop
 
I used the
Selection.EntireColumn.Insert
command at the point where i wanted the column inserted , it inserted
the column and won't process any more steps. Please Help. After
inserting the column, the code just stops and won't go any further
WITHOUT AN ERROR MESSAGE. Please Help

Code follows

Sub addcolumn()

Dim n As Integer
Dim Codecols As Integer
Dim Addcol As Boolean
Dim Delcol As Boolean
Application.Goto Reference:="colOffSet"
n = ActiveCell
Codecols = n + 5
Application.Goto Reference:="addcol"
Addcol = ActiveCell
Application.Goto Reference:="delcol"
Delcol = ActiveCell
Sheets("Ledger").Select
ActiveSheet.Unprotect
'
If Addcol = True Then
Sheets("Ledger").Select
Application.Goto Reference:="R1C" & Codecols
ActiveCell.Activate
Selection.EntireColumn.Insert
Range("B52").Select
Else
If Delcol = True Then
Sheets("Ledger").Select
Application.Goto Reference:="R1C" & Codecols
Selection.EntireColumn.Delete
End If
End If
RefreshRank
End Sub


Jim Cone

Inserting an entire column causes sub to stop
 
n2T,
Your codes says after inserting the column to select cell B52
and then run the RefreshRank procedure.
Is cell B52 selected?
Is the RefreshRank procedure running?
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"new2Texas"

wrote in message
I used the
Selection.EntireColumn.Insert
command at the point where i wanted the column inserted , it inserted
the column and won't process any more steps. Please Help. After
inserting the column, the code just stops and won't go any further
WITHOUT AN ERROR MESSAGE. Please Help

Code follows

Sub addcolumn()

Dim n As Integer
Dim Codecols As Integer
Dim Addcol As Boolean
Dim Delcol As Boolean
Application.Goto Reference:="colOffSet"
n = ActiveCell
Codecols = n + 5
Application.Goto Reference:="addcol"
Addcol = ActiveCell
Application.Goto Reference:="delcol"
Delcol = ActiveCell
Sheets("Ledger").Select
ActiveSheet.Unprotect
'
If Addcol = True Then
Sheets("Ledger").Select
Application.Goto Reference:="R1C" & Codecols
ActiveCell.Activate
Selection.EntireColumn.Insert
Range("B52").Select
Else
If Delcol = True Then
Sheets("Ledger").Select
Application.Goto Reference:="R1C" & Codecols
Selection.EntireColumn.Delete
End If
End If
RefreshRank
End Sub


JLGWhiz

Inserting an entire column causes sub to stop
 
Try stepping through the code manually to see if it goes to the RefreshRank
line. Since your references are not available it is difficult for me to see
what happens, but it looks like it would step all the way through, if your
GoTo references are valid.

"new2Texas" wrote:

I used the
Selection.EntireColumn.Insert
command at the point where i wanted the column inserted , it inserted
the column and won't process any more steps. Please Help. After
inserting the column, the code just stops and won't go any further
WITHOUT AN ERROR MESSAGE. Please Help

Code follows

Sub addcolumn()

Dim n As Integer
Dim Codecols As Integer
Dim Addcol As Boolean
Dim Delcol As Boolean
Application.Goto Reference:="colOffSet"
n = ActiveCell
Codecols = n + 5
Application.Goto Reference:="addcol"
Addcol = ActiveCell
Application.Goto Reference:="delcol"
Delcol = ActiveCell
Sheets("Ledger").Select
ActiveSheet.Unprotect
'
If Addcol = True Then
Sheets("Ledger").Select
Application.Goto Reference:="R1C" & Codecols
ActiveCell.Activate
Selection.EntireColumn.Insert
Range("B52").Select
Else
If Delcol = True Then
Sheets("Ledger").Select
Application.Goto Reference:="R1C" & Codecols
Selection.EntireColumn.Delete
End If
End If
RefreshRank
End Sub




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com