How do I loop an excel 2010 table by using his name & column reference?

I’m not very familiar with the shorthand method of referring to tables. If you don’t get an answer, you might find this longhand method, that uses the ListOject model, useful: Sub ListTableColumnMembers() Dim lo As Excel.ListObject Dim ws As Excel.Worksheet Dim lr As Excel.ListRow Set ws = ThisWorkbook.Worksheets(2) Set lo = ws.ListObjects(“tabWorkers”) For Each lr … Read more

VBA Excel – IFERROR & VLOOKUP error

Using Application.WorksheetFunction.VLookup( will break the code if the value is not found. Wrap it in vba error control. Function CCC(A As Range) Dim B As Variant B = -1 On Error Resume Next B = Application.WorksheetFunction.VLookup(A.Value, Sheets(“DAP”).Range(“$B$4:$X$7”), 5, False) On error goto 0 CCC = B End Function Another method is to Late Bind by … Read more

Excel VBA wildcard search

You can use Like operator (case-sensitive): Private Sub search_Click() For firstloop = 3 To 10 If Range(“G” & firstloop).Text Like name.Text & “*” Then MsgBox “Found!” Exit Sub Else MsgBox “NOT FOUND” End If Next End Sub for case-insensitive search use: If UCase(Range(“G” & firstloop).Text) Like UCase(name.Text) & “*” Then Also if you want to … Read more

VBA recognizing workbook by partial name

Yes you can use the LIKE Operator with a wildcard “*”. Here is an example. I am assuming that the workbook is open. Sub Sample() Dim wb As Workbook Dim wbName As String ‘~~> “MyWorkbook2015” wbName = “MyWorkbook” For Each wb In Application.Workbooks If wb.Name Like wbName & “*” Then Debug.Print wb.Name With wb.Sheets(“My_Sheet_Name_That_Does_Not_Change”) ‘~~> … Read more