+ Reply to Thread
Results 1 to 2 of 2

Excel Crashes with my code!

Hybrid View

  1. #1
    Registered User
    Join Date
    06-18-2014
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Excel Crashes with my code!

    I have got another challenge now though I need to place multiple rows so when I change the RANGE to, for example J6:DG100 it crashes VBA and excel. Any tricks to get this working for me?
    Sub Add_Checkboxes_Across()
      Dim myCBX As CheckBox
      Dim myCell As Range
      Dim RAN As Range
    
     'Sheets.Add  'for testing
      Set RAN = ActiveSheet.Range("J6:DG6")
      Application.ScreenUpdating = False
      With ActiveSheet
            .CheckBoxes.Delete
          For Each myCell In RAN
    
         With myCell
                   .RowHeight = 24
                   .Offset(0, 0).RowHeight = 24
                   .Offset(0, 0).VerticalAlignment = xlDistributed
                   .Offset(0, 0).HorizontalAlignment = xlCenter
                   .Offset(0, 0).RowHeight = 24
              Set myCBX = .Parent.CheckBoxes.Add _
                  (Top:=.Top, _
                   Width:=12, _
                   Left:=.Left + ((.Width - 12) / 2), _
                   Height:=.Height)
                   
              With myCBX
                  .LinkedCell = myCell.Offset(0, 0).Address(external:=True)
                  .Caption = ""
                  .Value = xlOff
              End With
          
          End With
          
          Next myCell
          
          With Range("J6:DG6")
            .HorizontalAlignment = xlCenter
          End With
          
      End With
      Application.ScreenUpdating = True
      End Sub
    Last edited by Leith Ross; 05-06-2015 at 12:47 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Excel Crashes with my code!

    Hello Laingy24,

    Your code ran fine for me and I am running Office 2010 on Windows 7. Have you tried restarting your computer or defragmenting the registry?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel crashes when I change code
    By leinadw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2014, 08:21 AM
  2. Excel always crashes at the very same point of the code
    By freakygreeneyes in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-31-2013, 09:59 AM
  3. My code crashes excel
    By ben_sumner in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-06-2006, 03:20 AM
  4. Excel crashes when code runs, Please help.
    By Potoroo in forum Excel General
    Replies: 2
    Last Post: 09-12-2006, 08:39 PM
  5. VBA WinInet Code Crashes Excel
    By curt.lindner@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2006, 12:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1