• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 70
  • Last Modified:

Check Excel range

How to check current selection range with Excel VBA and show

1. Row and cell number
2. Current cell content

Tks
0
AXISHK
Asked:
AXISHK
2 Solutions
 
Anthony BerenguelCommented:
to get the address of the current cell
activecell.address

Open in new window

current cell content
activecell.value

Open in new window

0
 
Wayne Taylor (webtubbs)Commented:
1. Row and cell number

    Activecell.Row or Activecell.Column

2. Current cell content

    Activecell.Value
0
 
AXISHKAuthor Commented:
But how to loop through all active row and cell and display the content one by one ? Tks
0
 
Rgonzo1971Commented:
Hi,

pls try

Sub Macro()
For Each c In Selection
    Debug.Print c.Address
    Debug.Print c.Value
Next
End Sub

Open in new window

Regards
0
 
Anthony BerenguelCommented:
(press ctrl+g from the vba editor to see the immediate window)
Public Sub LoopThroughRange()
    Dim thisRange As Range
    Set thisRange = Selection
    Dim thisCell As Range
    For Each thisCell In thisRange
        Debug.Print "activecell.address: " & thisCell.Address & ", ",
        Debug.Print "activecell.value: " & thisCell.value
    Next
End Sub

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now