Get the data part of a stuctured column in VBA

Anonym
2024-10-17T14:39:27+00:00

This will get me a column of data from a structred table

Function GetNameColumn() As Range

Dim ws As Worksheet 

Dim tbl As ListObject 

Dim colName As ListColumn 

Set ws = Sheets(SheetName) 

Set tbl = ws.ListObjects(TableName) 

Set colName = tbl.ListColumns(NamesColumnName) 

Set GetNameColumn = colName.Range 

End Function

I use the result in a for each loop but I'm obviously not interested in the header cell.

How do I skip the first item in the foreach? Is this the only option?

Dim NameCell As Range 

For Each NameCell In GetNameColumn()

    If NameCell.Value = NamesColumnName Then 

        GoTo NextCell 

    End If

NextCell:

Next NameCell
Microsoft 365 und Office | Excel | Für das Bildungswesen | Windows

Gesperrte Frage. Diese Frage wurde aus der Microsoft-Support-Community migriert. Sie können darüber abstimmen, ob sie hilfreich ist, aber Sie können keine Kommentare oder Antworten hinzufügen oder der Frage folgen.

0 Kommentare Keine Kommentare
Antwort, die vom Frageautor angenommen wurde
Anonym
2024-10-18T03:33:11+00:00

Diese Antwort wurde automatisch übersetzt. Daher können grammatikalische Fehler oder seltsame Formulierungen vorkommen.

Try this one in your macro.
    Set GetNameColumn = colName.DataBodyRange ' Use DataBodyRange to exclude the header

War diese Antwort hilfreich?

Eine Person fand diese Antwort hilfreich.
0 Kommentare Keine Kommentare

0 zusätzliche Antworten

Sortieren nach: Neueste