Hi there,
I am currently pulling my hair out over what I thought was a simple piece of code.
Basically I want to access a cell value using the range function. However, I need to access the row and columbn seperately as I am wanting to use activecell.row on the row and then just hardcode in the column.
The line Im using is below but doesnt seem to be giving me bak the answer I want, any idea's?
wsCD is my sheet I'm working on.Code:MsgBox (wsCD.Range((Cells(ActiveCell.Row, 5))).Value)
Cheers,
Jag
Perhaps
Code:MsgBox wsCD.Cells(ActiveCell.Row,5).Value
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thanks for the reply, but it still doesnt seem to work for the purposes I need it.
Howcome when I use it within the following method, it doesnt return a value when I call msgbox?
Cheers,Code:Public Sub example1() Dim wsCD As Worksheet, wsNew As Worksheet Dim HL As Hyperlink Dim rngCopy As Range, HLrange As Range On Error GoTo ExitPoint Application.ScreenUpdating = False Set wsCD = Sheets("Compartment Details") Set wsNew = Sheets.Add(After:=Sheets(Sheets.Count)) For Each HL In wsCD.Hyperlinks HLrange = HL.Range MsgBox (HLrange.Value) 'tried using the function here to display the hyperlink cell value wsCD.Activate: HL.Follow Set rngCopy = ActiveCell.Offset(, 1 - ActiveCell.Column).Resize(, 20) wsNew.Cells(wsNew.Rows.Count, "A").End(xlUp).Offset(1).Resize(, 20).Value = rngCopy.Value Set rngCopy = Nothing Next HL ExitPoint: Set wsCD = Nothing Set wsNew = Nothing Application.ScreenUpdating = True End Sub
Jag
You must Set the range object (and good idea to release thereafter)
That said the above could potentially generate a LOT of dialogs... if it's more for testing perhaps use Debug over MsgBox, ie:Code:Set HLRange = HL.Range MsgBox HLRange.Value Set HLRange = Nothing
and use Immediate window in VBE to see the output(s)Code:Debug.Print HLRange.Address & ":" & HLRange.Value
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks