Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default selecting more than one cell

Hi, Im trying to select more than one cell depending on a value in
another cell.
For i = 3 To 33

If Range("d" & i) = "True" Then
Range("as" & i).Select
End If
Next i

there could be several cells, so I want to select them all, or they
may alternate. Simular to using the control button when selecting
various cells. 99% of the time they will be grouped together, so Im
guessing I could select the first cell the offset to select the next.
I dont know though how to select more than one cell this way.
Regards Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default selecting more than one cell

First, we need to know what is actually in the cells you are trying to
match... is it Excel's TRUE or is it really the text "True"? If text, is the
text always an upper case T followed by lower case letters?

Rick


"RobcPettit" wrote in message
...
Hi, Im trying to select more than one cell depending on a value in
another cell.
For i = 3 To 33

If Range("d" & i) = "True" Then
Range("as" & i).Select
End If
Next i

there could be several cells, so I want to select them all, or they
may alternate. Simular to using the control button when selecting
various cells. 99% of the time they will be grouped together, so Im
guessing I could select the first cell the offset to select the next.
I dont know though how to select more than one cell this way.
Regards Robert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default selecting more than one cell

Separate the ranges with commas

Range("A1,B2:B4,C3").Select

I don't know if there's a limit on the number of ranges you can specify in
this manner.

"RobcPettit" wrote:

Hi, Im trying to select more than one cell depending on a value in
another cell.
For i = 3 To 33

If Range("d" & i) = "True" Then
Range("as" & i).Select
End If
Next i

there could be several cells, so I want to select them all, or they
may alternate. Simular to using the control button when selecting
various cells. 99% of the time they will be grouped together, so Im
guessing I could select the first cell the offset to select the next.
I dont know though how to select more than one cell this way.
Regards Robert

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default selecting more than one cell

Dim myRng as range
dim i as long
set myrng = nothing
for i = 3 to 33
if activesheet.cells(i,"D").value = true then
if myrng is nothing then
set myrng = activesheet.cells(i,"D")
else
set myrng = union(myrng, activesheet.cells(i,"D"))
end if
end if
next i

if myrng is nothing then
msgbox "Nothing to select!"
else
myrng.select
end if




RobcPettit wrote:

Hi, Im trying to select more than one cell depending on a value in
another cell.
For i = 3 To 33

If Range("d" & i) = "True" Then
Range("as" & i).Select
End If
Next i

there could be several cells, so I want to select them all, or they
may alternate. Simular to using the control button when selecting
various cells. 99% of the time they will be grouped together, so Im
guessing I could select the first cell the offset to select the next.
I dont know though how to select more than one cell this way.
Regards Robert


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default selecting more than one cell

Thanks all, Dave's worked perfect. Thanks again.
Regards Robert
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
Excel 2007 single cell selecting muliple cell Submit2s Excel Worksheet Functions 1 February 12th 09 04:52 PM
Selecting a cell entry based on cell validation selection Brutalius Excel Worksheet Functions 2 December 17th 08 03:44 AM
Transfer cell values to another cell by selecting button. Gryndar Excel Worksheet Functions 2 November 24th 08 02:21 AM
enter text in cell just by selecting cell dlyon Excel Programming 2 December 15th 07 06:37 PM
Selecting 10 charcters on one cell and pasting to another cell [email protected] Excel Programming 10 February 26th 07 07:56 PM


All times are GMT +1. The time now is 05:34 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"