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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2003 - How to set variable using selected row and a column? 1

Status
Not open for further replies.

DBLoser

MIS
Apr 7, 2004
92
US
I'm trying to define a variable based on the value of a cell. The column is static but the row is ActiveCell.Row. I can't find how to reference it.

Something like: MyVariable = (B,ActiveCell.Row)

...where B is the column and ActiveCell.Row is the row I need. The example above doesn't work but it's what I'm trying to accomplish.

Many Thanks!
 

hi,

You supply the column number...
Code:
MyVariable = cells(ActiveCell.Row, YourColumnNumber).value

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I get Run-time error '1004':

Application-defined or object-defined error

Here's the code:

Public MyVariable As String
Sub ApplyHyperlink()

MyVariable = Cells(ActiveCell.Row, BQ).Value

Sheets("Master").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=MyVariable

End Sub

In the code window when I mouseover the ActiveCell.Row variable, it does contain the the row number but BQ = empty. I am sure there is a UNC path & filename in that cell.
 
I get Run-time error '1004':

Application-defined or object-defined error

Here's the code:

Code:
Public MyVariable As String
Sub ApplyHyperlink()

    MyVariable = Cells(ActiveCell.Row, BQ).Value
    
    Sheets("Master").Select
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=MyVariable
    
End Sub
In the code window when I mouseover the ActiveCell.Row variable, it does contain the the row number but BQ = empty. I am sure there is a UNC path & filename in that cell.
 


what value in BQ? EMPTY, cuz you wanted Column BQ, yes?
Code:
Public MyVariable As String
Sub ApplyHyperlink()

    MyVariable = Cells(ActiveCell.Row, "BQ").Value[b]

'Your VARIABLE has NO ADDRESS!!!    [/b]
    
End Sub

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
That was it. Thank you very much!

Have a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top