Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a range from excel in VB

Status
Not open for further replies.

pcrosby78

Technical User
Feb 6, 2002
11
US
I have a cell that i have typed a range in.

I am writing a function in VB to use as a macro in excel, but i need to be able to use the range in the cell A1, so how can i tell VB goto cell A1 and use its contents as a range. so i can then use the macro to copy / paste items in that range back into other parts of my worksheet?

Example contents in cell A1:
B100:B500

thanks a lot
punx!
 
Hi punx
summat like
Range(Range("a1").Value).Select
should do the trick

;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Alternate method:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As String

If Not Target.Address = "$A$1" Then Exit Sub
rng = Target.Value
Range(rng).Select

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top