Kevin Jones
Kevin Jones

Reputation: 429

Add value to a specific row in a table using VBA

I want to add some value to a specific row in my table without having to reference the cell number

I have this

Dim LO As ListObject
Set LO = Sheets(1).ListObjects("table1")

LO.ListColumns("USER").DataBodyRange = "John"

However, this would repeat for every row in my table, how do I get it so its just a single row without having to specifically reference a cell if possible

Upvotes: 0

Views: 3450

Answers (1)

user4039065
user4039065

Reputation:

You've narrowed down the relevant cells to the single USER column sans header. Just add your relative row number to DataBodyRange.

Dim LO As ListObject
Set LO = Sheets(1).ListObjects("table1")

'put 'John' in first row of USER
LO.ListColumns("USER").DataBodyRange(1) = "John"

Upvotes: 2

Related Questions