OFFSET

Emm

Board Regular
Joined
Nov 29, 2004
Messages
165
Hi All,

Can someone help with this ...

I want to Offset cell b5 by the value in (k5 minus 1) multiplied by 18

in other words

say b5 =8

then the offset should be (8-1) x 18

= 126

I have tried setting x as a variable ... but keep getting errors..


thanks ....
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
did you try

=OFFSET($B$5,($K$5-1)*18,0,1,1)

that means it will gives value in B131

is this what you want.
 
Upvote 0
No .. want I want to do is use "offset" in VBA to take me to the cell ... not return the value from that cell..

Thanks..
 
Upvote 0
Emm

You haven't said whether you want to offset rows or columns, but I am assuming rows. Try the code below, remembering that usually you do not need to actually select a cell to work with it.

This code will select B131 if K5 contains 8 (I am assuming that your example of B5 containing 8 was meant to be K5). That is it selects the cell offset from B5 by 126 rows. Is that what you want?
Code:
Range("B5").Offset((Range("K5").Value - 1) * 18).Select
 
Upvote 0
Hi Peter..

just tried it ... comes up with error ..

Application or Object defined error

??

keith
 
Upvote 0
Hi Peter..

just tried it ... comes up with error ..

Application or Object defined error

??

keith
Perhaps you had better tell us more about your sheet(s) and what else you are trying to do. Also posting all of your existing code might be useful - providing it isn't tooooo long.
 
Upvote 0
Ok... got it Peter..

Thanks for your help ...

( i didn't have a value in K5 in my test sheet)


Doh!

Works OK now ...

Keith
 
Upvote 0
This will get you the same thing without Offset:

Code:
Range("B" & (Range("K5") - 1) * 18 + 5).Select

Although depending on what you are trying to do, you may not even need to Select, ranges can be worked with directly in VBA.
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,220
Members
448,876
Latest member
Solitario

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