Inserting an entire column causes sub to stop

  • Thread starter Thread starter new2Texas
  • Start date Start date
N

new2Texas

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
 
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"
<[email protected]>
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top