Offset VBA Problem

  • Thread starter Thread starter jlclyde
  • Start date Start date
J

jlclyde

I am writting code to clear an area of a spread sheet. I have the
upper left hand cell selected, but I need to be able to offset from
this point and go down 6 rows and 6 columns. So instead of just
selecting A1 it woudl select A1:F7.

Thanks in advance,
Jay
 
One way:

Range("A1").Resize(7, 6).ClearContents

Note that you almost never need to select a range - working directly
with the range object makes your code smaller, faster, and IMO, easier
to maintain...
 
Jay,

Range(Selection, Cells(Selection.Row + 6, Selection.Column + 6)).Select
Or more easily
Selection.Resize(6, 6).Select

You might want to put questions like these in microsoft.public.excel.programming

--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com

Note: Top-posting has been the norm here.
Some folks prefer bottom-posting.
But if you bottom-post to a reply that's
already top-posted, the thread gets messy.
When in Rome...
 
One way:

Range("A1").Resize(7, 6).ClearContents

Note that you almost never need to select a range - working directly
with the range object makes your code smaller, faster, and IMO, easier
to maintain...




- Show quoted text -

Thank you for the help. I will keep that in mind when writting future
code.
Jay
 
Back
Top