Hi,
This is my first try. I am developing mini project in Excel VBA. I have get some errors (object required) while calling function.. Kindly solve this problem.
Thanks & Regards.
This is my first try. I am developing mini project in Excel VBA. I have get some errors (object required) while calling function.. Kindly solve this problem.
VBA Code:
Sub recentrecord()
Dim lastrow, i As Long
'Dim ws As Worksheet
Call Activate_Cluster
lastrow = Application.WorksheetFunction.CountA(ws.Range("A:A")) - 1
UserForm1.Label8.Caption = lastrow
If lastrow <> 0 Then
'lastrow = Worksheets("Cluster-1").Cells(Rows.Count, 1).End(xlUp).Row
lastrow = Application.WorksheetFunction.CountA(ws.Range("A:A"))
UserForm1.Label4.WordWrap = False
UserForm1.Label4.FontSize = 10
UserForm1.Label4.Caption = ws.Cells(lastrow, 1) & "-A " & ws.Cells(lastrow, 5)
UserForm1.Label12.Caption = ws.Cells(lastrow, 11)
UserForm1.cmdUpdateRec.Enabled = True
UserForm1.cmdDelRec.Enabled = True
Else
UserForm1.Label4.Caption = "No Record Entered"
UserForm1.cmdUpdateRec.Enabled = False
UserForm1.cmdDelRec.Enabled = False
End If
End Sub
'calling function
Public Sub Activate_Cluster()
Dim SName As String
Dim ws As Worksheet
If Cluster1.Value = True Then
clrsno = 1
Set ws = ThisWorkbook.Sheets("Cluster-1")
ws.Activate
ws.Select
SName = ws.Name
Call lb2
ElseIf Cluster2.Value = True Then
clrsno = 2
Set ws = ThisWorkbook.Sheets("Cluster-2")
ws.Activate
ws.Select
SName = ws.Name
Call lb2
Else
clrsno = 3
Set ws = ThisWorkbook.Sheets("Cluster-3")
ws.Activate
ws.Select
SName = ws.Name
Call lb2
End If
End Sub
Thanks & Regards.