I am trying to select a column dynamically based on the Column headers in VBA. This is the code that I am using ,
Sub trial()
Dim colm As Long
Dim nwb As Workbook, wb As Workbook
Dim nwk As Worksheet, wk As Worksheet, wk1 As Worksheet
co1m = WorksheetFunction.Match("Header", Sheets("Sheet1").Rows(1), 0)
Columns(colm).Select
End Sub
when I try to debug it, it shows the value of 5 in colm and at the same time on the next line columns(colm).select, it shows 0 in the place of colm. Kindly help me with where I am going wrong in this. Thanks in advance