sgmpatnaik
Active Member
Hello
i am try to do a new data entry type that is when i open the excel file a UserForm will display and it is fine for me but there is one problem that is when i enter the data with UserForm then i got one error msg kindly suggest me which line i forget to add
in the workbook module i gave the below code
[pre]
[/pre]
i got the error MSG for the first line as
Run-time error1004
Method 'sheets' of object_'Global'failed
and when i press the debug button then a yellow line is display for the first line that is
nextrow = WorksheetFunction.CountA(Sheets("Dispatch Register".Range("B:B") + 4[/code][/pre]
Kindly suggest me what is the wrong i have done
Thanks
SP
i am try to do a new data entry type that is when i open the excel file a UserForm will display and it is fine for me but there is one problem that is when i enter the data with UserForm then i got one error msg kindly suggest me which line i forget to add
in the workbook module i gave the below code
[pre]
Code:
Private Sub Workbook_Open()
Dim wb As Workbook
For Each wb In Application.Workbooks
wb.Windows(1).WindowState = xlMinimized
'wb.Windows(1).WindowState = xlMinimized
Next
ThisWorkbook.Windows(1).Visible = False
GateWay.Show vbModeless
End Sub
in the UserForm i gave the below module
[pre][code]Private Sub CommandButton1_Click()
Dim nextrow As Integer
'=COUNTA (B:B)+4
nextrow = WorksheetFunction.CountA(Sheets("Dispatch Register").Range("B:B")) + 4
Sheets("Dispatch Register").Unprotect Password:="1243" 'replase password with actual password
Sheets("Dispatch Register").Cells(nextrow, 2) = Dispatch_Register.TextBox1.Value
Sheets("Dispatch Register").Cells(nextrow, 4) = Dispatch_Register.ComboBox1.Value
Sheets("Dispatch Register").Cells(nextrow, 5) = Dispatch_Register.TextBox2.Value
Sheets("Dispatch Register").Cells(nextrow, 6) = Dispatch_Register.TextBox3.Value
Sheets("Dispatch Register").Cells(nextrow, 7) = Dispatch_Register.TextBox4.Value
Sheets("Dispatch Register").Cells(nextrow, 8) = Dispatch_Register.TextBox5.Value
Sheets("Dispatch Register").Cells(nextrow, 9) = Dispatch_Register.TextBox6.Value
'Sheets("Dispatch Register").Cells(nextrow, 11) = Dispatch_Register.TextBox7.Value
Sheets("Dispatch Register").Cells(nextrow, 12) = Dispatch_Register.ComboBox2.Value
Sheets("Dispatch Register").Cells(nextrow, 10) = Dispatch_Register.TextBox7.Value
Sheets("Dispatch Register").Cells(nextrow, 13) = Dispatch_Register.TextBox8.Value
Sheets("Dispatch Register").Cells(nextrow, 15) = Dispatch_Register.ComboBox3.Value
Sheets("Dispatch Register").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingHyperlinks:=True, AllowFiltering _
:=True, AllowUsingPivotTables:=True, Password:="1243" 'replace password with actual password
'Clear The Text
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
ComboBox1.Value = ""
TextBox7.Value = ""
ComboBox2.Value = ""
TextBox8.Value = ""
ComboBox3.Value = ""
End Sub
i got the error MSG for the first line as
Run-time error1004
Method 'sheets' of object_'Global'failed
and when i press the debug button then a yellow line is display for the first line that is
nextrow = WorksheetFunction.CountA(Sheets("Dispatch Register".Range("B:B") + 4[/code][/pre]
Kindly suggest me what is the wrong i have done
Thanks
SP