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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Question.

Status
Not open for further replies.

KiwiGuy

Technical User
Mar 13, 2001
15
GB
Hey All,

Does anyone know how to create/change a range in excel vba. I want to be able to select a range say Col1 and Col3 then change that range so it looks at Col1 and Col5, Col1 will always be the same in the range but the second column selected could be any column, im using this to create a graph on the fly.

Cheers

Ben
 
to select the "A" and the "D" columns:
Range("A:A,D:D").Select

the following example selects the "A" and the "D" columns, assig it to the myRange, sends the selection's address, then changes myRange to ("A1:A20,D1:D20") and so on..

dim myRange as Range
Set myRange = Range("A:A,D:D")
myRange.Select
MsgBox Selection.Address
Set myRange = Range("A1:A20,D1:D20")
myRange.Select
MsgBox Selection.Address
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top