Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 447

Is it a good practice to use list objects/ tables in an excel sheet rather than referencing it as data range? [closed]

$
0
0

I am having an excel sheet with multiple tables like data ranges inside. I have to pull data from these tables and also write into the tables as well. these are not tables so, I decided to change them to tables through VBA and then access the cell values. I need to update a alphanumerical value in the cell besides item num.

Like the first table should have A1 and the next table item num is A2 and so on.... Please help me to write a loop to convert the ranges into respective tables and update the item value.

I tried this code to change all my data ranges to tables using the first reference cell value as "game. Name"

Sub Test1()    Dim lr As Long, i As Integer    Dim cll As Range, rng As Range    With ActiveSheet        lr = .Cells(Rows.Count, 1).End(xlUp).Row        Set rng = .Range("A1:A" & lr)        i = 0        For Each cll In rng            If cll.Value = "game. Name" Then 'find header row                i = i + 1 'count table                .ListObjects.Add(xlSrcRange, .Range(cll, cll.End(xlDown).Offset(, 3)), , xlYes).Name = "Table" & i 'create table            End If        Next cll    End WithEnd Sub

Viewing all articles
Browse latest Browse all 447

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>