Value of cell next to a cell defined as an object

mchac

Well-known Member
Joined
Apr 15, 2013
Messages
531
I've set an object by using .find to identify a cell.

Set ACCTS_PAYABLE_OBJECT = Sheets(BAL_SHT_TAB_NAME).Range(TAG_RANGE).Find(SEARCH_STRING, LookIn:=xlValues, LookAt:=xlPart)

Is there a cleaner way to get the value of the cell in the next column to the right from the object cell?

Right now I'm using:
ACCTS_PAYABLE_VALUE = Worksheets(BAL_SHT_TAB_NAME).Cells(ACCTS_PAYABLE_OBJECT.Row, 2).Value

but I thought I had read something that gets the value more easily/directly but I can't find it now.

If anyone has an idea on this I would appreciate the help.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
In this case, you'll probably want to use Offset. Here's an example....

Code:
Dim thisCell As Range
Set thisCell = Sheets("Sheet1").Cell(1, "A")

Dim OffsetValue As String
OffsetValue = thisCell.Offset(0, 1).Value

It's used in this fashion....

Offset(row, column)

So with a 1 in the column, it will offset the object to the right by one cell.

or you could use -1 and get the value in the previous column.

Same would go for rows higher or lower, it would just be in the row position instead.

In theory you might be able to use...

Code:
ACCTS_PAYABLE_VALUE = ACCTS_PAYABLE_OBJECT.Offset(0, 1).Value

but that would be if the object is a range. How is the object declared?
 
Last edited:
Upvote 0
Good question. I didn't know what declaration to use so left it as a variant.
ACCTS_PAYABLE_VALUE = ACCTS_PAYABLE_OBJECT.Offset(0, 1).Value does work and I think that's what I had read. I've now declared it as a Range and everything still works.
Thanks RJ
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top