Strange results from offset formula

Uncle Max

New Member
Joined
Feb 5, 2018
Messages
4
Can anyone tell me what the problem is with this code snippet?

Range("D5").Formula = "=match(D6,ChTables!$A:$A,)"
Range("D7").Formula = "=OFFSET(ChTables!A1,D5,53)"
Range("D8").Formula = "=OFFSET(ChTables!A1,D5,47)"
Range("D9").Formula = "=OFFSET(ChTables!A1,D5,51)"
Range("D10").Formula = "=OFFSET(ChTables!A1,D5,72)"

The code for "D5", D7" & "D9" return the correct answers, although "D7" adds a decimal number to the referenced integer!

"D8" & "D10" both return 0, although the function arguments box (fx) show the correct numbers, so I must have the correct references.

Advice would be much appreciated
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
MATCH() will return 1 for row 1, 2 for row 2 etc. You should also have a final parameter ideally (zero for exact match)
To use the value in D5 with your offset formula you'll need to subtract 1 from that value in order to find the right row.

Code:
Range("D5").Formula = "=MATCH(D6,ChTables!$A:$A,0)"
Range("D7").Formula = "=OFFSET(ChTables!A1,D5-1,53)"
Range("D8").Formula = "=OFFSET(ChTables!A1,D5-1,47)"
Range("D9").Formula = "=OFFSET(ChTables!A1,D5-1,51)"
Range("D10").Formula = "=OFFSET(ChTables!A1,D5-1,72)"

Not sure what you're doing, however, since you're adding a volatile function into the sheet which will make it slow. It might be better to just fetch the value you want rather than using the formula option.

WBD
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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