![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 22
|
Hi everyone !
I've search previous postings and I've found nothing yet. I need a macro to select a few cells without knowing in advance which range it will be. Ex: If my active cell is on range 3, I want to select D3,E3 and G3. If my active cell in on range 5, I want to select D5, E5 and E5. Thanks a lot everybody ! |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
What is range 3, 5?
Tom |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
You want to select, D,E, and G of the active row, correct?
If so, try, ------------------- Sub tester() Dim x As Long x = ActiveCell.Row Range("D" & x & ",E" & x & ",G" & x).Select End Sub ------------------- HTH, Jay |
|
|
|
|
|
#4 | |
|
New Member
Join Date: Apr 2002
Location: England
Posts: 44
|
Quote:
Also do you mean D3,E3, G3 for range 2 and D5,E5,(E5 or G5) for range 5. Cheers, Alan |
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2002
Posts: 22
|
Thanks a lot Jay Petrulis !
Sorry I didn't explain my problem right but you gave me the answer I need. Thanks again ! |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Posts: 85
|
You could also try the "xlspecialcells" function.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|