Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lucille Holmes   on Aug 25 In MS Office Category.

  
Question Answered By: Martha Gonzalez   on Aug 25

If you can display the range you want to select in a MsgBox, you are almost
there.
Here is a sub with 2 examples of displaying a range in a Msgbox, then
selecting that range.

Sub AAAAA()
'Declare variables
Dim Row1 As Long, Row2 As Long, Row3 As Long, Row4 As Long
Dim Col1 As Integer, Col2 As Integer, Col3 As String, Col4 As String
'Assign values to variables
Row1& = 1
Row2& = 21
Row3& = 11
Row4& = 31
Col1% = 2
Col2% = 7
Col3$ = "E"
Col4$ = "I"
'Select using numerical column references
MsgBox "Range(Cells(" & Row1& & "," & Col1% & "), Cells(" & Row2& & "," &
Col2% & "))"
Range(Cells(Row1&, Col1%), Cells(Row2&, Col2%)).Select
'Select using alphabetical column references
MsgBox "Range(" & Col3$ & Row3& & ":" & Col4$ & Row4& & ")"
Range(Col3$ & Row3& & ":" & Col4$ & Row4&).Select
End Sub

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on I'm stuck . . . can you help, please? Or get search suggestion and latest updates.


Tagged: