Solved

Check Excel range

Posted on 2015-02-03
5
58 Views
Last Modified: 2016-02-10
How to check current selection range with Excel VBA and show

1. Row and cell number
2. Current cell content

Tks
0
Comment
Question by:AXISHK
5 Comments
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 40587772
to get the address of the current cell
activecell.address

Open in new window

current cell content
activecell.value

Open in new window

0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 40587773
1. Row and cell number

    Activecell.Row or Activecell.Column

2. Current cell content

    Activecell.Value
0
 

Author Comment

by:AXISHK
ID: 40587942
But how to loop through all active row and cell and display the content one by one ? Tks
0
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 200 total points
ID: 40587960
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
 
LVL 10

Accepted Solution

by:
Anthony Berenguel earned 300 total points
ID: 40587962
(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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now