Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Get Content of cells(row,column) if its a variable


Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2005, 01:11 AM
a1jit a1jit is offline
Junior Contributor
 
Join Date: Oct 2004
Posts: 293
Default Get Content of cells(row,column) if its a variable


Hi Guys

Now i have a string variable..it stores the cells position..for example

str = cells(1,1)
str1 = cells(1,2)

how do i get the value of this cells?

cause i tried str -> but it gives cells(1,1) which it suppose to give..
How can i get the content of cells(1,1) by using str..

THank You..
Reply With Quote
  #2  
Old 08-30-2005, 07:28 AM
davheili's Avatar
davheili davheili is offline
Centurion
 
Join Date: Jul 2003
Location: Wisconsin
Posts: 109
Default

If I'm reading your question correctly, you have a cell that contains an address to another cell, of which you want to get the value of.

This sounds overly simple, so I'm probably wrong. But if not, you could use something like:
Code:
MsgBox Range(Range("A3").Address).Value
where cell A3 contains the address to another cell.

Hope this helps. Dave
Reply With Quote
  #3  
Old 08-30-2005, 09:37 AM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

Quote:
Originally Posted by davheili
Code:
MsgBox Range(Range("A3").Address).Value
Did you actually tried that...

Think you are after this:
Code:
Dim Str As String Str = Cells(1, 3).Address MsgBox Range(Str).Value
Reply With Quote
  #4  
Old 08-30-2005, 01:17 PM
davheili's Avatar
davheili davheili is offline
Centurion
 
Join Date: Jul 2003
Location: Wisconsin
Posts: 109
Default

Quote:
Originally Posted by italkid
Did you actually tried that...
italkid. Yep your right. It don't work. Apparently there's a flaw in my cut / paste process. Yea, Yea. That's it... A flaw in cut / paste. That's my story and I'm sticking with it.

Actually I think I meant
Code:
MsgBox Range(Range("A3").Value).Value
Reply With Quote
  #5  
Old 08-30-2005, 09:35 PM
a1jit a1jit is offline
Junior Contributor
 
Join Date: Oct 2004
Posts: 293
Default

Hi,
Sorry for the confusing explanation..

Actually i meant..

Lets say now the content of cells(1,1) is cells(1,2)

means if i put
msgbox cells(1,1)

the output i get is
"cells(1,2)" as string

So how do i get the value in cells(1,2) as "cells(1,2)" is a string?
Reply With Quote
  #6  
Old 08-30-2005, 10:43 PM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

Quote:
Originally Posted by a1jit
So how do i get the value in cells(1,2) as "cells(1,2)" is a string?
?? that is still confusing me...

If you are after the contents of Cells(1, 2) then you'll have to pull the number out of that string to be able to use them in a valid range reference. Otherwise you might store that address as B1 instead of Cells(1, 2), and use an INDIRECT() formula to get the cell's contents...
Reply With Quote
  #7  
Old 08-30-2005, 11:22 PM
a1jit a1jit is offline
Junior Contributor
 
Join Date: Oct 2004
Posts: 293
Default

Ok, sorry

Actually i myself am confused..

Now i have a series of cells stored in a particular cell..for an example
cells(1,1) has this content in it

"cells(1,2)|cells(1,8)|cells(2,1)|cells(1,9)"

something like that..so i split it by "|"

so i get
array(0) = cells(1,2)
array(1) = cells(1,8)
ETC..

so now, each of this array is of type string..

the problem is the i want to get the value of array(0) - means the value in cells(1,2) ..

whenever i do array(0) -> i get cells(1,2)

So how do i get the value of cells(1,2)
Reply With Quote
  #8  
Old 08-31-2005, 09:24 AM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

Ok, in the first place, why those cell addresses (and in that particular format) in a cell?

Conserning your array... you could use text functions to get the row and column number out of each array item. Replace() for instance "Cells(" and ")" by "", and the result would be "1, 2", then get everything to the Left() from the comma, and everything to the Right() of the space...

Btw, don't start other threads about the same issue as long this particular issue is not solved (I deleted it)...have some patience
Reply With Quote
  #9  
Old 08-31-2005, 07:21 PM
a1jit a1jit is offline
Junior Contributor
 
Join Date: Oct 2004
Posts: 293
Default

sorry italkid..i wont repeat it again...ok..thx for the idea..

Last edited by a1jit; 08-31-2005 at 07:27 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->