Solved

Excel VBA and cell value

Posted on 2012-03-12
4
257 Views
Last Modified: 2012-03-12
I have a variable on a sheet that changes based on the row being read while the loop is executed.

Dim rowIndex as Integer
Dim SourceRange as Variant
SourceRange = ("A2")

In the loop I have this;
SourceRange = ("A") & rowIndex

The SourceRange is changing properly as the loop is executed, BUT,

I am trying to figure out of the variable SourceRange contains a string.  How do I get that value from SourceRange?  

Thanks.
0
Comment
Question by:TechPilot9133
  • 2
4 Comments
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 37711755
Dim SourceRange as Range
SourceRange = ("A2")
MsgBox SourceRange.Value
0
 
LVL 8

Expert Comment

by:2toria
ID: 37711758
You could try something like this:-


If Application.WorksheetFunction.IsText(SourceRange) = True Then

----->do something here

End If

Hope this helps,
Matt
0
 
LVL 8

Expert Comment

by:2toria
ID: 37711773
Actually, this is better:-

If VarType(SourceRange) = vbString Then

---->Do something here

End If

Matt
0
 

Author Closing Comment

by:TechPilot9133
ID: 37712163
That answer does exactly what I asked, but it does not help me whith what I am trying to do.  I will do further tests and hopefully formulate my question better.  Sometimes finding the proper way to ask the question is the harder than us newbs think. Thank you for the responses.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
EXCEL Addin problem 7 27
Excel filter by strike though 8 26
From where do I download MySQL for Excel? 2 13
+1 to an even value 4 15
A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

744 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

12 Experts available now in Live!

Get 1:1 Help Now