Results 1 to 3 of 3

Thread: code for data entry in excel 2003

  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Exclamation code for data entry in excel 2003

    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

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: code for data entry in excel 2003

    An array of data can be transferred to a range of multiple cells at the same time, as follows.

    Dim oExcel As Object
    Dim oBook As Object
    Dim oSheet As Object

    'Start a new workbook in Excel.
    oExcel = CreateObject("Excel.Application")
    oBook = oExcel.Workbooks.Add

    'Create an array with 3 columns and 100 rows.
    Dim DataArray(99, 2) As Object
    Dim r As Integer
    For r = 0 To 99
    DataArray(r, 0) = "ORD" & Format(r + 1, "0000")
    DataArray(r, 1) = Rnd() * 1000
    DataArray(r, 2) = DataArray(r, 1) * 0.07
    Next

    'Add headers to the worksheet on row 1.
    oSheet = oBook.Worksheets(1)
    oSheet.Range("A1").Value = "Order ID"
    oSheet.Range("B1").Value = "Amount"
    oSheet.Range("C1").Value = "Tax"

    'Transfer the array to the worksheet starting at cell A2.
    oSheet.Range("A2").Resize(100, 3).Value = DataArray

    'Save the Workbook and quit Excel.
    oBook.SaveAs(sSampleFolder & "Book2.xls")
    oSheet = Nothing
    oBook = Nothing
    oExcel.Quit()
    oExcel = Nothing
    GC.Collect()

    source: http://support.microsoft.com/kb/306022

  3. #3
    johnvarenda Guest

    Re: code for data entry in excel 2003

    hi...
    I am new to data entry in excel..
    But your posting helps me to learn a lot..
    Can you explain how to add columns in DataGrid in VB.Net.
    Thanks in advance...
    .............

Similar Threads

  1. Replies: 3
    Last Post: 10-03-2012, 08:00 PM
  2. Preventing data entry duplication in excel
    By Duke Lawrence in forum Windows Software
    Replies: 2
    Last Post: 22-03-2010, 08:11 PM
  3. Prevent duplication of data entry in Excel
    By Chhaya in forum Windows Software
    Replies: 6
    Last Post: 15-12-2009, 06:06 PM
  4. How to convert Excel file data into XML code
    By Arif15 in forum Software Development
    Replies: 3
    Last Post: 20-10-2009, 07:21 PM
  5. Replies: 4
    Last Post: 23-12-2008, 06:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,178,285.01140 seconds with 17 queries