Edit Named Table Data from a Userform

39 views Asked by At

I've created a Excel Userform that contains a listbox linked to a named table. I want to be able to select an item within the list box then edit the data in the linked name table. Sheet Name is "Dips" Table Name is "DipTable" Table headings are in cells B46:J46

I am having some success with the following code in that it will successfully change the cell value of the first item, so it will correctly update cell B"i" with Me.Chainage.Value and stop there. If I were to delete out the line associated with column B, it would correctly update cell C"i" with Me.Dip1.Value. Its like it gives up using i after the updating the first cell.

Dim ws As Worksheet
Set ws = Worksheets("Dips")

i = Me.listboxDips.ListIndex + 47

With ws
    .Range("B" & i).Value = Me.Chainage.Value
    .Range("C" & i).Value = Me.Dip1.Value
    .Range("D" & i).Value = Me.Dip2.Value
    .Range("E" & i).Value = Me.Dip3.Value
    .Range("F" & i).Value = Me.Dip4.Value
    .Range("G" & i).Value = Me.Dip5.Value
    .Range("H" & i).Value = Me.Dip6.Value
    .Range("I" & i).Value = Me.Dip7.Value
    .Range("J" & i).Value = Me.CommentBox.Value
End With

I have the exact same issue if I try using an alternative method to locate the cell that needs updating. I have also used

ws.Cells(i,2).Value = Me.Chainage.Value

Any help would be greatly appreciated.

0

There are 0 answers