ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   setting a variable to the offset of another object declared variab (https://www.excelbanter.com/excel-programming/429017-setting-variable-offset-another-object-declared-variab.html)

ironhydroxide

setting a variable to the offset of another object declared variab
 
I am having problems with offset. i cant seem to get the offset function to
set a variable to the offset of another variable (a cell) here are a couple
code snippits that i have tried already.

Set PopFromZone = Selection.Offset(0, 2)
If PopFromZone = "Zone AV" Then ' type Error 13 Type Mismatch

If PopFrom.Offset(0, 2) = "Zone AV" Then 'Run Time error 434 Object
Required

Thanks for replies

Ironhydroxide



Jacob Skaria

setting a variable to the offset of another object declared variab
 
1. check your declartion. Declare as Range

2. popfromzone. or PopFrom.


--
If this post helps click Yes
---------------
Jacob Skaria


"ironhydroxide" wrote:

I am having problems with offset. i cant seem to get the offset function to
set a variable to the offset of another variable (a cell) here are a couple
code snippits that i have tried already.

Set PopFromZone = Selection.Offset(0, 2)
If PopFromZone = "Zone AV" Then ' type Error 13 Type Mismatch

If PopFrom.Offset(0, 2) = "Zone AV" Then 'Run Time error 434 Object
Required

Thanks for replies

Ironhydroxide



Bernie Deitrick

setting a variable to the offset of another object declared variab
 
Rusty,

For the first one, you need to limit yourself to one cell:

If PopFromZone.Cells(1) = "Zone AV" Then

The second one.... well, you are not setting PopFrom as a range anywhere, and you need to limit to
one cell.

HTH,
Bernie
MS Excel MVP


"ironhydroxide" wrote in message
...
I am having problems with offset. i cant seem to get the offset function to
set a variable to the offset of another variable (a cell) here are a couple
code snippits that i have tried already.

Set PopFromZone = Selection.Offset(0, 2)
If PopFromZone = "Zone AV" Then ' type Error 13 Type Mismatch

If PopFrom.Offset(0, 2) = "Zone AV" Then 'Run Time error 434 Object
Required

Thanks for replies

Ironhydroxide





ironhydroxide

setting a variable to the offset of another object declared va
 
exactly what was needed. Thanks


"Bernie Deitrick" wrote:

Rusty,

For the first one, you need to limit yourself to one cell:

If PopFromZone.Cells(1) = "Zone AV" Then

The second one.... well, you are not setting PopFrom as a range anywhere, and you need to limit to
one cell.

HTH,
Bernie
MS Excel MVP


"ironhydroxide" wrote in message
...
I am having problems with offset. i cant seem to get the offset function to
set a variable to the offset of another variable (a cell) here are a couple
code snippits that i have tried already.

Set PopFromZone = Selection.Offset(0, 2)
If PopFromZone = "Zone AV" Then ' type Error 13 Type Mismatch

If PopFrom.Offset(0, 2) = "Zone AV" Then 'Run Time error 434 Object
Required

Thanks for replies

Ironhydroxide







All times are GMT +1. The time now is 08:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com