Solved

Check Excel range

Posted on 2015-02-03
5
62 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 50

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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 demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

730 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