Hi,
I am struggling with vba code which is supposed to do the following:
[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Employee[/TD]
[TD]Region[/TD]
[TD]Sales[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]John[/TD]
[TD]Spain[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Mike[/TD]
[TD]UK[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Peter[/TD]
[TD]Germany[/TD]
[TD]30[/TD]
[/TR]
</tbody>[/TABLE]
In the TABLE (not range) I need that row 3 until last row is deleted and that the second row for columns ID:Region that this row is cleared content; column Sales has formula based on the three first columns
I have the following code which is not working:
Sub Test()
Dim loSource As Excel.ListObject
Dim laSource As Excel.ListObject
Set loSource = Sheets("Sales").ListObjects("Table1")
loSource.ListObjects(2).DataBodyRange.Delete Shift:=xlShiftUp
Set laSource = Sheets("Sales").ListObjects("Table1")
laSource.ListColumns.Range("Table1[[ID]:[Region]]").Select
Selection.ClearContents
End Sub
Thank you
I am struggling with vba code which is supposed to do the following:
[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Employee[/TD]
[TD]Region[/TD]
[TD]Sales[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]John[/TD]
[TD]Spain[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Mike[/TD]
[TD]UK[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Peter[/TD]
[TD]Germany[/TD]
[TD]30[/TD]
[/TR]
</tbody>[/TABLE]
In the TABLE (not range) I need that row 3 until last row is deleted and that the second row for columns ID:Region that this row is cleared content; column Sales has formula based on the three first columns
I have the following code which is not working:
Sub Test()
Dim loSource As Excel.ListObject
Dim laSource As Excel.ListObject
Set loSource = Sheets("Sales").ListObjects("Table1")
loSource.ListObjects(2).DataBodyRange.Delete Shift:=xlShiftUp
Set laSource = Sheets("Sales").ListObjects("Table1")
laSource.ListColumns.Range("Table1[[ID]:[Region]]").Select
Selection.ClearContents
End Sub
Thank you