View Single Post
 
Old 07-28-2014, 04:51 AM
jamierbooth jamierbooth is offline Windows XP Office XP
Novice
 
Join Date: Feb 2011
Posts: 4
jamierbooth is on a distinguished road
Default Deleting info from specific table cells

Hi world.... I'm having trouble getting some code to work. (obviously, or I wouldn't be writing this!) To try and de-clutter an already enormous form....

From a command button, a table is copied and pasted below the existing table and I also want to remove the contents of selected cells. I've cobbled together some code that copies and pastes, and found somewhere that tells me what code to use to delete cell contents, however this bit isn't working for me. Code is below, I've commented out the delete bit that isn't working.

Code:
Private Sub cmdBookings_Click()
    With ActiveDocument
        .Tables(23).Range.Copy
        .Range.Select
        Selection.GoTo what:=wdGoToBookmark, Name:="AfterTable23"
        Selection.MoveUp
        Selection.Paste
        Selection.GoTo what:=wdGoToBookmark, Name:="AfterTable23"
        Selection.MoveUp
        Selection.InsertBreak Type:=wdSectionBreakContinuous
        'ActiveDocument.Tables(23).Cells(1, 2).Select
        'Selection.Delete
    End With
End Sub
To add a bit more:

- User completes form - this particular table (23) shows accommodation bookings.
- User will need to come back to form to add further bookings.
- User then would (when it works) click button to send old info to bottom in a new table and clear out the existing table for another booking.
- User may need to add 3 or 4 accommodation bookings within same form.

Any help would be great. Also I struggle to understand the .Cells(1, 2) bit. How does that address the particular cell. Row 1, column 2 ?? or am I barking up the wrong tree?

Thanks!!!! Jamie.
Reply With Quote