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.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!
- NikolinoDEGold Contributor
- hrh_dashIron 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
- NikolinoDEGold 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.