Can´t open Form

KhallP

Board Regular
Joined
Mar 30, 2021
Messages
157
Office Version
  1. 2016
Platform
  1. Windows
I have an Excel sheet (Sheet3) that contains 3 buttons, "Print", "Clear" and "Start", the program yesterday was working correctly until an error appears when I try to open a Form that is available and that exists, someone can help?


Rich (BB code):
Private Sub cmd_Clear_Click()
    Range("A14:A125").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.ClearContents
    Selection.Interior.ColorIndex = xlNone
    Selection.Font.bold = False
    Selection.Font.Italic = False
    Selection.Font.Underline = xlUnderlineStyleNone
    Range("B6:D10").Select
    Selection.ClearContents
    Range("B6:D6").Select
End Sub

Private Sub cmd_Print_Click()
    Application.ScreenUpdating = False
    Range("A5:J58").Select
    ActiveSheet.PageSetup.PrintArea = "$A$5:$J$58"
    Range("D15").Select
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = "$A$5:$J$58"
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.75)
        .RightMargin = Application.InchesToPoints(0.75)
        .TopMargin = Application.InchesToPoints(0.5)
        .BottomMargin = Application.InchesToPoints(0.5)
        .HeaderMargin = Application.InchesToPoints(0.5)
        .FooterMargin = Application.InchesToPoints(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = False
        .PrintErrors = xlPrintErrorsDisplayed
    End With
  
    Range("A1").Select
    Application.ScreenUpdating = True
    Application.Dialogs(xlDialogPrint).Show

End Sub


Private Sub cmd_Start_Click()

Error there!!!!!!
------------------
Dates.Show
----------------

End Sub
 
Last edited by a moderator:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
In the VB Editor, click Tools - Options, select the General tab, and change the error handling option to Break in class module. Then try your code again and it should highlight the actual error line.
 
Upvote 0
In the VB Editor, click Tools - Options, select the General tab, and change the error handling option to Break in class module. Then try your code again and it should highlight the actual error line.
The error is there:

VBA Code:
Private Sub UserForm_Initialize()
    
    Workbooks.Open Filename:=Environ("userprofile") & "\Documents\Projeto\Corrections_Data.xlsm"
    Workbooks("Corrections_Data.xlsm").Sheets("AC_Offset_Registers").Range("BI2:B13").Value = "Negative"
   [COLOR=rgb(97, 189, 109)] Error there!!!!!!!!!!!![/COLOR]!
    -------------------------------------------------------
    k_machine = Workbooks("Corrections_Data.xlsm").Sheets("AC_Offset_Registers").Cells(Rows.Count, "B").End(xlDown).Offset(1).Row
    -----------------------------------------------
    Date_Today = Format(Now, "dd/mm/yyyy")
    hour = Format(Now, "hh:mm")
    lb_date_resp.Caption = Date_Today
    Me.cb_machinename.AddItem "A4"
    Me.cb_machinename.AddItem "A8.1"
    Me.cb_machinename.AddItem "A8.2"
    Me.cb_machinename.AddItem "A8.3"
    Me.cb_machinename.AddItem "A12.1"
    Me.cb_machinename.AddItem "A12.2"
    Me.cb_machinename.AddItem "A12.3"
    Me.cb_machinename.AddItem "A20.1"
    Me.cb_machinename.AddItem "A20.2"
    Me.cb_tec.AddItem "Horácio Guerra"
    Me.cb_tec.AddItem "Fernando Raposo"
    Me.cb_tec.AddItem "Ricardo Guerreiro"
    Me.cb_tec.AddItem "João Falardo"
    Me.cb_tec.AddItem "Fábio Teixeira"
    Me.cb_tec.AddItem "Luis Simões"
    Me.cb_correc.AddItem "Preventiva"
    Me.cb_correc.AddItem "Correctiva (Crash)"

End Sub
 
Upvote 0
It should be xlUp not xlDown in that line.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,467
Members
448,965
Latest member
grijken

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