Avatar of TechPilot9133
TechPilot9133
Flag for United States of America asked on

Excel VBA and cell value

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.
Microsoft Excel

Avatar of undefined
Last Comment
TechPilot9133

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Martin Liss

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
2toria

You could try something like this:-


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

----->do something here

End If

Hope this helps,
Matt
2toria

Actually, this is better:-

If VarType(SourceRange) = vbString Then

---->Do something here

End If

Matt
TechPilot9133

ASKER
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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy