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

Excel vba - Easy Range question

Status
Not open for further replies.

markozzz

IS-IT--Management
Feb 22, 2007
6
NO
Hi,
I couldnt figure this out..

In this sentence:
Code:
...Sheets("Sheet1").Range("G:J"), 4, False)
in .Range("G:J") i would like "G" to be a variable. Like .Range("(Var),J").. But that obviously doesnt work.

Help please?

Rgds,
Markozzz
 




Hi,

Take a look at the Cells property of range...
Code:
Sheets("Sheet1").Range("G:J")
iCol1 = Cells(1, "G").column
iCol2 = Cells(1, "J").column
Sheets("Sheet1").Range(Cells(1,iCol1), Cells(1,iCol2)).entirecolumn


Skip,

[glasses] [red][/red]
[tongue]
 
You may try this:
.Range(Var & ":J")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you both!
I used PHV`s method, but im sure it both works.

Rgds,
markozz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top