Results 1 to 10 of 10

Thread: VBA vs. Screen Size?
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Sep 2014
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA vs. Screen Size?

    I have several macros that run just fine on my desktop monitor but don't run at all on my laptop screen. There is no error message, they just don't run.

    They have the same resolution (1920x1080) but the laptop is 15.6" and the desktop is 22".

    What causes this and is there any way around it?

    Thanks in advance for your time,
    ~ Phil

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    49,669
    Post Thanks / Like
    Mentioned
    51 Post(s)
    Tagged
    11 Thread(s)

    Default Re: VBA vs. Screen Size?

    What exactly do these Macros do?
    Does a simple macro like:
    Code:
    Sub Test()
        MsgBox "Hi"
    End Sub
    work?

    Are these running from the same computer, or different computers?
    If different computers, I suspect the security settings set so that you have macros/VBA disabled on the one.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  3. #3
    Board Regular
    Join Date
    Sep 2014
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA vs. Screen Size?

    Joe4,

    It's the same computer. I have my laptop hooked up to a docking station and the laptop display & destop monitor are in extended screen mode.

    The little snippet that says "Hi" just fine on either screen. Here are the two macros in question.

    Code:
    Private Sub CommandButton1_Click()
    
    Dim sht As Worksheet
    Dim LastRow As Long
    Dim LastColumn As Long
    Dim StartCell As Range
    Application.ScreenUpdating = False
    
    Set sht = Worksheets("Tracking")
    Set StartCell = Range("A4")
    
    'Refresh UsedRange
        Worksheets("Tracking").UsedRange
    
    'Find Last Row and Column
        LastRow = StartCell.SpecialCells(xlCellTypeLastCell).Row
        LastColumn = StartCell.SpecialCells(xlCellTypeLastCell).Column
    
    'Select Range
        sht.Range(StartCell, sht.Cells(LastRow, LastColumn)).Select
        
    'Name the selected range
        Selection.Name = ("ecolist")
      
    'Sort the range
      Range("ecolist").Sort Key1:=Range("B4"), Order1:=xlAscending, Key2:=Range("A4"), Order2:=xlAscending, Header:=xlNo
        
    Application.ScreenUpdating = True
    
    End Sub
    
    Private Sub CommandButton2_Click()
    MSG1 = MsgBox("This action cannot be undone!" & vbCrLf & vbCrLf & "Selected Row is: " & ActiveCell.Row, 1, "CAUTION!")
    
    Application.ScreenUpdating = False
    
    If MSG1 = vbOK Then
    
        'Select row
            ActiveCell.EntireRow.Select
    
        'Return to Blank Format
            Selection.Interior.Color = xlNone
            Selection.Font.Strikethrough = False
            Selection.ClearContents
    End If
    
    Application.ScreenUpdating = True
    
    End Sub
    Thanks again for your time & assistance.

    ~ Phil
    Last edited by Philip1957; Apr 11th, 2019 at 01:43 PM.

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    49,669
    Post Thanks / Like
    Mentioned
    51 Post(s)
    Tagged
    11 Thread(s)

    Default Re: VBA vs. Screen Size?

    What if you try putting breakpoints near the top of the macros, and then click the buttons, and go into the VB Editor, and see if it is stopped at that point (and what happens if you continually hit F8 - watch to see if it goes through or bombs out somewhere)?
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  5. #5
    Board Regular
    Join Date
    Sep 2014
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA vs. Screen Size?

    It steps through with no problems, with & without stops. It does this with the VBAE on either screen, as well as when I'm undocked.

    I'm going to delete the command buttons from the sheet, recreate them, and reassign them. I don't see any reason why this would help, but who knows . . .

  6. #6
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    49,669
    Post Thanks / Like
    Mentioned
    51 Post(s)
    Tagged
    11 Thread(s)

    Default Re: VBA vs. Screen Size?

    Not a bad idea to try that.

    It does not make much sense to me that it would work when you step through it, but doesn't when you don't.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  7. #7
    Board Regular
    Join Date
    Sep 2014
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA vs. Screen Size?

    Finally had time to play with this. Buttons didn't make any difference.

    I have these macros in the worksheet, not in This Workbook or a module. I'm going to make modules and try that.

  8. #8
    Board Regular jmacleary's Avatar
    Join Date
    Oct 2015
    Location
    at a desk in the UK
    Posts
    555
    Post Thanks / Like
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA vs. Screen Size?

    Just a wild stab in the dark but maybe the screenupdating toggling you are doing works on the 'native' screen, but not on the docking screen? Maybe try taking out the screenupdating=false to see if they stay in sync. If that's it, then perhaps a recalc at the end might refresh things?
    If my answer has helped, please vote using the Thanks or Like buttons on the left.
    John

  9. #9
    Board Regular
    Join Date
    Sep 2014
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA vs. Screen Size?

    That was a good idea, but it didn't work. Thanks for the suggestion.

  10. #10
    Board Regular
    Join Date
    Sep 2014
    Posts
    109
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA vs. Screen Size?

    Re-did my macros as modules and they still wouldn't run when triggered from the ActiveX control button.

    Deleted the ActiveX controls and replaced them with buttons from Form Controls pointing to the modules. Works fine now.

    I still do not understand why it behaves this way.

    Anybody know how to change the background color of a Form Control button?

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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