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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
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

Emm

Board Regular
Joined
Nov 29, 2004
Messages
165
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

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
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

Emm

Board Regular
Joined
Nov 29, 2004
Messages
165
Hi Peter..

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

Application or Object defined error

??

keith
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
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

Emm

Board Regular
Joined
Nov 29, 2004
Messages
165
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

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,961
Office Version
  1. 365
Platform
  1. Windows
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,191,687
Messages
5,988,077
Members
440,125
Latest member
vincentchu2369

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
Top