Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with cell referencing

Status
Not open for further replies.

tonalator15

Technical User
Jun 22, 2009
2
US
Hi

I am new to this forum and am currently having trouble with VBA. I am trying to have my code go to the worksheet that is in the formula of another cell.

Example:

='Sheet1'!$A$1

I would like to be able to go to "Sheet1" and then select data from that sheet using more VBA code. Is there a way to follow the reference in a cell?

Thanks for any help in advance!
 



Hi,

Not really sure what you are asking.

You have a cell containing a formula. You want to find the SHEET and CELL?
Code:
'select the cell with the formula
Dim a, i As Integer, sTheSheet As String, sTheRange As String
With ActiveCell
   a = Split(.Formula, "!")
   If UBound(a) = 1 Then
      sTheSheet = Right(a(0), Len(a(0)) - 1)
      sTheRange = a(1)
   Else
      sTheSheet = ActiveSheet.Name
      sTheRange = Right(a(0), Len(a(0)) - 1)
   End If
End With


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip, I'd replace this:
[tt]sTheSheet = Right(a(0), Len(a(0)) - 1)[/tt]
with this:
[tt]sTheSheet = Mid(Replace(a(0), "'", ""), 2)[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top