Results 1 to 4 of 4

Single step works fine but command button has errors

Threaded View

  1. #1
    Registered User
    Join Date
    09-05-2017
    Location
    Woodinville, WA
    MS-Off Ver
    Office 2007
    Posts
    2

    Single step works fine but command button has errors

    I have a long but simple VBA program that hides rows in a spreadsheet depending upon options. Everything works fine when I single step through the program using F8. However, that is not the case when I use a command button to execute. For example, there are eight rows each for Slots C, D and E. For the specific variables, the coding should hide none of C, 4 of D and all of E in workbooks '700G Relay Setting Calcs' and 'Logic Variables'. It does so successfully with single step using F8. When pressing the command button within the spreadsheet, it hides 5 instead of 4 D in workbook '700G Relay Setting Calcs', and none of D and only 3 of E in workbook 'Logic Variables'.

    I don't understand how it would work using F8 but not work when runing the macro automatically. Any ideas on where to start looking for the issue? A sample portion of code follows:


    'Unhide all rows in Worksheets "700G Relay Setting Calcs" and "Logic Variables"
    Worksheets("700G Relay Setting Calcs").Rows("1:1000").Hidden = False
    Worksheets("Logic Variables").Rows("1:100").Hidden = False
    
      'Hide unavailable Slot C Output rows
      For I = Range("C_Outputs").Value + Range("Num_C_Out").Value To Range("C_Outputs").Value + 7
        Worksheets("700G Relay Setting Calcs").Rows(I).Hidden = True
      Next I
      For J = 45 + Range("Num_C_Out").Value To 52
        Worksheets("Logic Variables").Rows(J).Hidden = True
      Next J
      
      'Hide unavailable Slot D Output rows
      For I = Range("D_Outputs").Value + Range("Num_D_Out").Value To Range("D_Outputs").Value + 7
        Worksheets("700G Relay Setting Calcs").Rows(I).Hidden = True
      Next I
      For J = 53 + Range("Num_D_Out").Value To 60
        Worksheets("Logic Variables").Rows(J).Hidden = True
      Next J
     
      'Hide unavailable Slot E Output rows
      For I = Range("E_Outputs").Value + Range("Num_E_Out").Value To Range("E_Outputs").Value + 7
        Worksheets("700G Relay Setting Calcs").Rows(I).Hidden = True
      Next I
      For J = 61 + Range("Num_E_Out").Value To 68
        Worksheets("Logic Variables").Rows(J).Hidden = True
      Next J
    Last edited by CptCrunch51; 09-05-2017 at 03:22 PM. Reason: Added Code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Disable Insert button code works fine, but some times throws Run-Time error '5'
    By challasl in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-18-2016, 05:41 AM
  2. VBA Code works by step by step, doesn't work by running
    By lucasar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2016, 06:33 AM
  3. Command Button Works Sometimes
    By Scrapnforfun in forum Excel General
    Replies: 3
    Last Post: 07-31-2016, 01:24 PM
  4. [SOLVED] Help with modifying VBA Macro - Works fine but needs fine tuning !
    By stefan27 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-06-2015, 10:27 AM
  5. [SOLVED] vba code, command bar, command bar button, one button works but not two
    By amazingg64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 09:55 AM
  6. Replies: 6
    Last Post: 09-13-2005, 07:06 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