Solved

Using variables within the offset

Posted on 2007-03-21
2
145 Views
Last Modified: 2010-04-30
Here is a simplified version of what I am trying to do:
Dim State as integer, r as range
Set r = range("A1")
State = 10
If r.Offset(0, State).Value = "Texas" Then ....

Assuming r.offset(0,10).value does equal "Texas", what am I doing wrong in this line:
If r.Offset(0, State).Value = "Texas" Then ....
0
Comment
Question by:tiehaze
2 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 18767344
Hi tiehaze,

It look OK to me. Given that r=A1 and State=10,  r.Offset(0, State).Value gets the value from L1. Is this correct?

Regards,

Wayne
0
 

Author Comment

by:tiehaze
ID: 18767386
nevermind... i got it to work, thanks for the confidence :)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now