Hey Everyone!! I am a novice but really want to learn. Here is my code
Ok so far a column was found and a column was inserted to the right and named. In the co1m column there are names, and I want to paste a vlookup formula in the Sales_rep column that looks up the name in the same row and references a table on sheet2 A:B. I want it to paste formulas in Sales_Rep only up until the last row with a name in it, not to the end of the worksheet. I want to use r1c1 at least in this section, because additional columns could be added/deleted from the source workbook. I welcome questions and might ask for clarification even if a solution works so I can apply it in other needs. Thank you
VBA Code:
Sub trial()
Dim colm As Long
Dim nwb As Workbook, wb As Workbook
Dim nwk As Worksheet, wk As Worksheet, wk1 As Worksheet
Dim Sales_Rep As Long
co1m = WorksheetFunction.Match("Sales Representative Name", Sheets("Sheet1").Rows(1), 0)
Columns(co1m).Select
Columns(ActiveCell.Column + 1).Insert Shift:=xlToRight
Sales_Rep = ActiveCell.Column + 1
End Sub
Ok so far a column was found and a column was inserted to the right and named. In the co1m column there are names, and I want to paste a vlookup formula in the Sales_rep column that looks up the name in the same row and references a table on sheet2 A:B. I want it to paste formulas in Sales_Rep only up until the last row with a name in it, not to the end of the worksheet. I want to use r1c1 at least in this section, because additional columns could be added/deleted from the source workbook. I welcome questions and might ask for clarification even if a solution works so I can apply it in other needs. Thank you
Last edited by a moderator: