Find and overwrite an excel row in an Excel Table

ajay_gajree

Well-known Member
Joined
Jul 16, 2011
Messages
518
Hi All

I have a userform (Code below) that writes new data to a new row in an Excel Table.

What I also want to build is the ability to search for a row in the database (Column A in the table is a primary key) and then allow a user to overwrite the data as per the userform.

Not too sure how to go about this so any advice or if anyone can suggest where to look on the internet for some assistance would be great!

Code:
Private Sub cmdAdd_Click()
Dim oNewRow As ListRow
Dim rng As Range
    
Set rng = ThisWorkbook.Worksheets("BRP Database").Range("tblBRPDatabase")
    
ThisWorkbook.Worksheets("BRP Database").Select
rng.Select
    
    Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
    With rng
        oNewRow.Range.Cells(1, 2).Value = Format(Me.cboQtr.Value, "MMM-YY")
        oNewRow.Range.Cells(1, 4).Value = Me.cboBusiness.Value
        oNewRow.Range.Cells(1, 5).Value = Me.cboLvl2.Value
        oNewRow.Range.Cells(1, 6).Value = Me.cboRAG.Value
        oNewRow.Range.Cells(1, 7).Value = Me.cboForwardLook.Value
        oNewRow.Range.Cells(1, 8).Value = Me.txtCommentary.Value
        oNewRow.Range.Cells(1, 9).Value = Me.cboLvl1RiskAppetiteRAG.Value
        oNewRow.Range.Cells(1, 9).Value = Me.cboLvl2RiskAppetiteRAG.Value
        
    End With
    'Clear input controls.
    Me.cboQtr.Value = ""
    ThisWorkbook.Worksheets("Non Financial BRP Dashboards").Select
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top