MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 08:05 PM   #1
dpmicka
 
Join Date: Jun 2002
Location: North Carolina
Posts: 119
Default Select cells based on certain number of rows and columns...

I'd like to set up a macro or some code that would select a range of cells that is 8 columns wide by 15 rows high and copy it to clipbaord no matter what particular cell is selected at any given time I might run the macro. In other words, if I had cell A2 selected and I ran the macro, cells in range A2:H16 would be selected then copied to clipboard. If I happened to be in cell K20 and ran the macro, then range K20:R34 would be selected then copied to clipboard. I hope I explained this clearly enough - any ideas???
dpmicka is offline   Reply With Quote
Old Mar 30th, 2004, 08:11 PM   #2
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 9,090
Default Re: Select cells based on certain number of rows and columns

Sub Test1()
Dim AR As Long, AC As Integer
AR = ActiveCell.Row
AC = ActiveCell.Column
Range(Cells(AR, AC), Cells(AR + 14, AC + 7)).Copy
End Sub
__________________
Tom Urtis
Tom Urtis is offline   Reply With Quote
Old Mar 30th, 2004, 08:12 PM   #3
Smitty
MrExcel MVP
Moderator
 
Smitty's Avatar
 
Join Date: May 2003
Location: Boulder Creek, CA
Posts: 18,775
Default Re: Select cells based on certain number of rows and columns

How's this:

Sub SelectMe()
****With ActiveCell
********Range(ActiveCell, ActiveCell.Offset(14, 7)).Copy
****End With
End Sub


You'll need to add a copy to range, or you could add an InputBox to prompt for it.

Hope that helps,

Smitty
Smitty is offline   Reply With Quote
Old Mar 30th, 2004, 08:37 PM   #4
dpmicka
 
Join Date: Jun 2002
Location: North Carolina
Posts: 119
Default Re: Select cells based on certain number of rows and columns

Both work great!!! Thanks very much!!!
dpmicka is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 12:33 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.