dear friends,
I am new to this forum. So I greet you all.
I am new to vb code also.
Directly I entered to the issue that when I trying to data enter through a sheet in excel to make entry in the another sheet of same workbook, nothing happened. I got only the message "Data entered successfully". the code I used is reproduced here:
Private Sub CommandButton5_Click()
'add data through data entry form
'Update data on Sheet1 based on changes made through data entry on Sheet2
Dim LEntry As Integer
Dim LName As String
Dim LDept As String
Dim LPhone As String
Dim LAreaRepn As String
Dim LPrejudice As String
Dim LRow As Long
Dim LFound As Boolean
Application.ScreenUpdating = False
'Retrieve membership number
LEntry = Range("I71").Value 'please read I71 as I 71, I for Ink
'Retrieve data information
LName = Range("I72").Value
LDept = Range("I73").Value
LPhone = Range("I74").Value
LAreaRepn = Range("I75").Value
LPrejudice = Range("I76").Value
'unprotect the worksheet & workbook
Worksheets("Sheet1").Unprotect Password:="pass"
ActiveWorkbook.Unprotect Password:="pass"
'Move to Sheet1 to save the changes
Sheets("Sheet1").Visible = True
Sheets("Sheet1").Select
'LFound = False
LRow = 2
Do While LFound = True
'Found matching project, now update data
If DEntry = Range("A" & LRow).Value Then
LFound = True
Range("D" & LRow).Value = LName
Range("E" & LRow).Value = LDept
Range("F" & LRow).Value = LPhone
Range("G" & LRow).Value = LAreaRepn
Range("H" & LRow).Value = LPrejudice
'Encountered a blank membership number (assuming end of list on Sheet1)
ElseIf IsEmpty(Range("A" & LRow).Value) = True Then
MsgBox ("No member was found. Data are not made.")
Exit Sub
End If
LRow = LRow + 1
Loop
'Sheets("Sheet1").Visible = False
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
.DisplayFormulas = False
End With
'protect the worksheet & workbook
Worksheets("Sheet1").Protect Password:="pass"
ActiveWorkbook.Protect Password:="pass"
'Reposition back on Sheet2
Sheets("Sheet2").Select
Range("I71").Select
'save data
ActiveWorkbook.Save
MsgBox ("Data entered successfully")
any one can help me. Thanks
End Sub
Bookmarks