Solved

Excel VBA and cell value

Posted on 2012-03-12
4
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 47

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

688 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