Solved

Check Excel range

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

785 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