Forum Discussion
hrh_dash
Sep 07, 2022Iron Contributor
VBA to get value based on last column and using find
I would like to have a macro to get values from last column by executing a find function. There is no errors but currently it is not displaying any values. For example; based on the screenshot ws...
hrh_dash
Sep 08, 2022Iron Contributor
NikolinoDE , sorry would u be able to include a find function in the example? The reason for the find function is that my find variable (in this example is "MISC") may not always be the lastrow
NikolinoDE
Sep 08, 2022Gold Contributor
To quickly find something in the active worksheet, you can use the search function.
To do this, press CTRL+F and enter the search terms.
- hrh_dashSep 10, 2022Iron Contributor
Managed to figure out a solution for this, decided to put the solution for everyone's easy reference.
Dim Destwb_TCA As Workbook Dim Destws_TCA As Worksheet Dim find_TCA_MISC As Range Dim lastCol_TCA As Long Set Destwb_TCA = Workbooks.Open('indicate your workbook file path) Set Destws_TCA = Destwb_TCA.Sheets("Sum of Payment For invoicing") lastCol_TCA = Destws_TCA.Cells(2, Columns.Count).End(xlToLeft).Column 'looking at row 2 Set find_TCA_MISC = Destws_TCA.Range("A:A").Find(What:="MISC") 'Text "MISC" will always be in range("A:A") ws.Cells(3, lastCol).Value = Destws_TCA.Cells(find_TCA_MISC.Row, lastCol_TCA)