ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Linked cell location in VBA (https://www.excelbanter.com/excel-programming/379840-re-linked-cell-location-vba.html)

Jim Cone

Linked cell location in VBA
 
Seth,

Maybe...
Sub DoTheTwist()
If Worksheets("Data").Range("C10").Value = "N.G." Then
Worksheets("Matrix").Range("X62").Value = "N/A"
End If
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Seth"
wrote in message
I have two sheets I'm working with, called "Data" and "Matrix". I have a
simple macro to evaluate a cell (C10) in Data, and if the statement is true,
then I want to change a cell in Matrix to the text "N/A". Here's my problem,
the cell location I want to change is contained in cell C8 in Data and looks
like this:
=Matrix!$X$62

So far I have...

Sheets("Data").Select
For i = 3 To 149
If Cells(10, i) = "N.G." Then
????? = "N/A"
End If
Next

Thanks in advance!
Seth

Jim Cone

Linked cell location in VBA
 

Sub FindThePlaceWeWant()
Dim strLocation As String
Dim lngCol As Long
Dim N As Long
Dim i as Long

lngCol = 3
i = 8
N = InStr(1, Cells(i, lngCol).Formula, "!", vbTextCompare) + 1

strLocation = Mid$(Worksheets("Data").Cells(i, lngCol).Formula, N, 255)
Worksheets("Matrix").Range(strLocation).Value = "N/A"
End Sub
--
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html





"Seth"
wrote in message
I may not have been clear, I'm trying to get the cell location which is in a
linked cell, then using that location add text to another cell. The cells
that contain the locations are in row 8 (C8, D8, E8...) so I can't hardcode
a location into a function.

"Jim Cone" wrote:
Seth,

Maybe...
Sub DoTheTwist()
If Worksheets("Data").Range("C10").Value = "N.G." Then
Worksheets("Matrix").Range("X62").Value = "N/A"
End If
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Seth"
wrote in message
I have two sheets I'm working with, called "Data" and "Matrix". I have a
simple macro to evaluate a cell (C10) in Data, and if the statement is true,
then I want to change a cell in Matrix to the text "N/A". Here's my problem,
the cell location I want to change is contained in cell C8 in Data and looks
like this:
=Matrix!$X$62
So far I have...

Sheets("Data").Select
For i = 3 To 149
If Cells(10, i) = "N.G." Then
????? = "N/A"
End If
Next
Thanks in advance!
Seth




All times are GMT +1. The time now is 07:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com