Forum Discussion

hrh_dash's avatar
hrh_dash
Iron Contributor
Sep 07, 2022

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.Range("B31") would populate 117.83 based on the last column

 

The code as follows:

 

Dim find_2022_TCA As Range
Dim lastCol_TCA As Long
Dim Destws_TCA_corp As Worksheet


        Set find_2022_TCA = Destws_TCA_corp.Cells.Find(What:="MISC", After:=ActiveCell, LookIn:=xlValues _
    , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False)

    lastCol_TCA = Destws_TCA_corp.Cells(2, Columns.Count).End(xlToLeft).Column

   ws.Range("B31").Value = Destws_TCA_corp.Cells(find_2022_TCA, lastCol_TCA).Value

 

appreciate the help in advance!

Resources