Solved

update a excel database table

Posted on 2004-04-14
1
257 Views
Last Modified: 2010-04-17
i have one sheet with 5 cells that i want to go into a new line of a excel database on another sheet when i click on a update button.  one of the five cells is an order number and i would also like a button that when clicked asked for the order number, then populated the other cells with the info from the database.
0
Comment
Question by:chad201008
1 Comment
 
LVL 3

Accepted Solution

by:
elantra earned 250 total points
ID: 10826231
Here you go, the following code is for a button named "cmdSelectOrder".  You have to put the button on the sheet with all your order numbers.  I'm sure you could easily modify the code if you want it to do other things.

Private Sub cmdSelectOrder_Click()
    'Variables
    Dim strInput As String
    Dim rngOrders As Range
    Dim bolFound As Boolean
    Dim objDestination As Worksheet
   
    'Change to accomodate your destination sheet name
    Set objDestination = ActiveWorkbook.Sheets("Sheet2")
   
    'Prompt for input
    strInput = InputBox("Please enter an order number:", "Order Number")
   
    'Set the used range
    Set rngOrders = ActiveSheet.UsedRange
    'Count used range in sheet and loop through each line
    For i% = 1 To rngOrders.Rows.Count
        Cells(i%, 1).Select
        If ActiveCell.Value = strInput Then
            bolFound = True
            With ActiveCell.EntireRow
                .Copy objDestination.Range("a" & Rows.Count).End(xlUp).Offset(1, 0)
            End With
        End If
    Next i%
   
    'If the order was not found then display an error message
    If bolFound = False Then MsgBox "Invalid order number selected!"
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now