VBA vs. Screen Size?

Philip1957

Board Regular
Joined
Sep 30, 2014
Messages
185
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
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.
 
Upvote 0
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:
Upvote 0
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)?
 
Upvote 0
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 . . .
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top