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

How to return the location of a cell in Excel via VBA

Status
Not open for further replies.

phoenix26

Programmer
Dec 12, 2005
11
US
In VBA, I am trying to to return the exact location (column and row) of a cell in an Excel worksheet? Would someone please help me.

 
Have a look at the Column and Rowproperties:
MsgBox ActiveCell.Row & "," & ActiveCell.Column

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or Msgbox Activecell.Address?? Not sure where you're trying to go with this..

-----------
Regards,
Zack Barresse
 
Do you know if there is a way to determine if there are cells with any value that had not been included in the selected print range?

Thank you
 
HLEE1167, to answer your question, yes, you can. Like so ..

Code:
Sub CheckPrintAreaValues()
    Dim ws As Worksheet
    Dim rngPrint As Range, rngOdd As Range
    Set ws = Sheets("Sheet1")
    Set rngPrint = ws.Range(ws.PageSetup.PrintArea)
    Set rngOdd = ws.Range("A1", ws.Cells.SpecialCells(xlCellTypeLastCell))
    If Application.CountA(rngOdd) <> Application.CountA(rngPrint) Then
        MsgBox "you have values outside of your print area on sheet " & ws.Name & "!"
    End If
End Sub

-----------
Regards,
Zack Barresse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top