?
Solved

Check Excel range

Posted on 2015-02-03
5
Medium Priority
?
66 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 52

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 800 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 1200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

770 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