Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Karina K patni   on Mar 11 In MS Office Category.

  
Question Answered By: Norman Ray   on Mar 11

I'd be very surprised if there aren't much ways to do this, but this
is what works

To get the range:

Sub GetRangeAddress()
Dim S As Range
Dim letters As String, FirstLet As String, SecondLet As String
Dim ULCol As String, ULCell As String, LRCol As String, LRCell As
String
Dim c As String, r As Integer

Set S = Selection

'fast and easy (or is it hard and difficult?) conversion
letters = " A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
For i = 1 To 7
FirstLet = Mid$(letters, i * 2, 1)
For j = 1 To 26
SecondLet = Mid$(letters, j * 2, 1)
letters = letters & FirstLet & SecondLet
Next j
Next i
'get upper left of selection
If S.Column <= 26 Then _
ULCol = Mid$(letters, S.Column * 2, 1) _
Else _
ULCol = Mid$(letters, S.Column * 2 - 1, 2)
ULCell = ULCol & S.Row
'get last cell in selection.
For Each cl In S
r = cl.Row
c = cl.Column
Next

If c <= 26 Then _
LRCol = Mid$(letters, c * 2, 1) _
Else _
LRCol = Mid$(letters, c * 2 - 1, 2)
LRCell = LRCol & r
ThisRange = ULCell & ":" & LRCell
End Sub


To just print  the selection, unless I'm mising something:

Selection.PrintOut Copies:=1

Share: 

 
 
Didn't find what you were looking for? Find more on returning the address of a highlighted area Or get search suggestion and latest updates.


Tagged: