Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Selecting Multiple Cells

When you are in an excel file you can select multiple cells my clicking in
the first cell and then dragging across or down to the last cell, or by
Control + Click. Is there a was for me to pick several cells from inside a
VBA project. The main problem is that I dont know which cells I want to
select. The program runs though looking for matches to cells in the first
column and then when it finds one it is suppose to select the next 5 cells in
that row.
Thank you very much for the help,
Jordan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting Multiple Cells

set rng = cell.Find("ABCD")
if not rng is nothing then
set rng = rng.Resize(1,5)
' or if you don't want the found cell
' set rng = rng.offset(0,1).Resize(1,5)
rng.Select
end if

--
Regards,
Tom Ogilvy

"Jordan" wrote in message
...
When you are in an excel file you can select multiple cells my clicking in
the first cell and then dragging across or down to the last cell, or by
Control + Click. Is there a was for me to pick several cells from inside

a
VBA project. The main problem is that I don't know which cells I want to
select. The program runs though looking for matches to cells in the first
column and then when it finds one it is suppose to select the next 5 cells

in
that row.
Thank you very much for the help,
Jordan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Selecting Multiple Cells

Jordan,

Assuming that the cell you find is active, you can use

Activecell.Resize(1,5).Select

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jordan" wrote in message
...
When you are in an excel file you can select multiple cells my clicking in
the first cell and then dragging across or down to the last cell, or by
Control + Click. Is there a was for me to pick several cells from inside

a
VBA project. The main problem is that I don't know which cells I want to
select. The program runs though looking for matches to cells in the first
column and then when it finds one it is suppose to select the next 5 cells

in
that row.
Thank you very much for the help,
Jordan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting Multiple Cells

typo:
set rng = cell.Find("ABCD")
should be

set rng = cells.Find("ABCD")

but that was just a "placeholder" for the code you are using.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
set rng = cell.Find("ABCD")
if not rng is nothing then
set rng = rng.Resize(1,5)
' or if you don't want the found cell
' set rng = rng.offset(0,1).Resize(1,5)
rng.Select
end if

--
Regards,
Tom Ogilvy

"Jordan" wrote in message
...
When you are in an excel file you can select multiple cells my clicking

in
the first cell and then dragging across or down to the last cell, or by
Control + Click. Is there a was for me to pick several cells from

inside
a
VBA project. The main problem is that I don't know which cells I want

to
select. The program runs though looking for matches to cells in the

first
column and then when it finds one it is suppose to select the next 5

cells
in
that row.
Thank you very much for the help,
Jordan





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Selecting Multiple Cells

try this vba programm("g" is your match)

Public Sub test()
Range("a1").Select

Cells.Find(what:="g").Activate
Dim lastcell As Range
Set lastcell = ActiveCell.Offset(0, 5)
Dim myrange As Range
Set myrange = Range(ActiveCell.Offset(0, 1), lastcell)
myrange.Select

End Sub

Jordan wrote in message
...
When you are in an excel file you can select multiple cells my clicking in
the first cell and then dragging across or down to the last cell, or by
Control + Click. Is there a was for me to pick several cells from inside

a
VBA project. The main problem is that I don't know which cells I want to
select. The program runs though looking for matches to cells in the first
column and then when it finds one it is suppose to select the next 5 cells

in
that row.
Thank you very much for the help,
Jordan





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Selecting Multiple Cells

Just an example, finds a cell containing "a" and
then selects that cell + additional 5 cells down that row.

For Each c In Sheet1.UsedRange.Cells.End(xlUp)
If c.Value = "a" Then
Range(c.Address & ":" & c.Offset(5, 0).Address).Select
End If
Next


Sharad


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Selecting Multiple Cells

Awesome, thanks a lot

"Tom Ogilvy" wrote:

typo:
set rng = cell.Find("ABCD")
should be

set rng = cells.Find("ABCD")

but that was just a "placeholder" for the code you are using.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
set rng = cell.Find("ABCD")
if not rng is nothing then
set rng = rng.Resize(1,5)
' or if you don't want the found cell
' set rng = rng.offset(0,1).Resize(1,5)
rng.Select
end if

--
Regards,
Tom Ogilvy

"Jordan" wrote in message
...
When you are in an excel file you can select multiple cells my clicking

in
the first cell and then dragging across or down to the last cell, or by
Control + Click. Is there a was for me to pick several cells from

inside
a
VBA project. The main problem is that I don't know which cells I want

to
select. The program runs though looking for matches to cells in the

first
column and then when it finds one it is suppose to select the next 5

cells
in
that row.
Thank you very much for the help,
Jordan






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select multiple adjacent cells of multiple cells without selecting sjsjsjsjsjs New Users to Excel 11 December 24th 09 01:09 AM
Select multiple adjacent cells of multiple cells without selecting sjsjsjsjsjs Excel Worksheet Functions 7 December 23rd 09 08:54 PM
Selecting Multiple Cells Richard Stedman Excel Discussion (Misc queries) 3 March 12th 09 10:59 PM
How do I keep from selecting multiple cells Ricochet Excel Worksheet Functions 2 April 29th 08 06:11 PM
How to change shade of cells when selecting multiple cells abrummet Excel Discussion (Misc queries) 3 September 6th 07 11:42 AM


All times are GMT +1. The time now is 09:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"