• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA: In a Table, how to place cursor on 1st row of an nth column?

inddon

Member
Hello There,

I have a Table and a few columns. I would like to place the cursor on the 1st row and on 9th column.

Table Name is : Table1
Column Name where the cursor will be placed: Division

This is how my code is setup and used across the workbook:

Code:
Public wsRaw As Worksheet, tbl1 As ListObject

    'Setting worksheet and Table1
    Set wsRaw = Worksheets("RawData")
    Set tbl1 = wsRaw.ListObjects("Table1")

Currently, I am using the below code, which works fine

Code:
ActiveSheet.ListObjects("Table1").DataBodyRange(1, 9).Select

I would prefer to have in the above code, the table name list object (tbl1) and column name (Division), and not (1, 9) as in the future there might be new columns before 'Division'.


Could you please advise how this can be achieved


Look forward to hearing from you.

Thanks & regards,
Don
 
You can do something like...
Code:
Public wsRaw As Worksheet, tbl1 As ListObject
Dim dCol as Range
'Setting worksheet and Table1
Set wsRaw = Worksheets("RawData")
Set tbl1 = wsRaw.ListObjects("Table1")
Set dCol = tbl1.ListColumns("Division").DataBodyRange
dCol(1).Select
 
Back
Top