Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

setting Range from address

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Raj - 26 May 2008 17:32 GMT
Hi,

Depending on the value of Range("a1"), a range address is stored in
Range ("b1") as follows: Master!$B$31:$B$52. How can I use the  value
in Range("b1") to set a range in vba code?

Any other suggestions also welcome.

Thanks in advance for the help.

Regards,
Raj
Rick Rothstein (MVP - VB) - 26 May 2008 17:44 GMT
Something like this...

  Set MyRange = Range(Range("B1").Value)

or this...

  Set MyRange = Range(Cells(1, "B").Value)

(depending on how you need to reference the range) should work.

Rick

> Hi,
>
[quoted text clipped - 8 lines]
> Regards,
> Raj
Norman Jones - 26 May 2008 17:51 GMT
Hi Raj,

Try something like:

'==========>>
Public Sub TestIt()
   Dim WB As Workbook
   Dim SH As Worksheet
   Dim sStr As String
   Dim arr As Variant
   Dim rng As Range

   Set WB = ThisWorkbook                 '<<==== CHANGE
   Set SH = WB.Sheets("DataSheet")    '<<==== CHANGE

   sStr = ActiveSheet.Range("B1").Value
   arr = Split(sStr, "!")

   Set rng = WB.Sheets(arr(0)).Range(arr(1))
   MsgBox rng.Address(External:=True)
End Sub
'<<==========

---
Regards.
Norman

> Hi,
>
[quoted text clipped - 8 lines]
> Regards,
> Raj
Norman Jones - 26 May 2008 17:58 GMT
Hi Raj,

As Rick demonstrates, it is not necessary
to split the text in the cell.

Therefore, go with Rick's better and simpler
sugestion.

---
Regards.
Norman
Raj - 27 May 2008 03:05 GMT
Thanks.It worked

On May 26, 9:58 pm, "Norman Jones" <normanjo...@wherforartthou.com>
wrote:
> Hi Raj,
>
[quoted text clipped - 7 lines]
> Regards.
> Norman
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.