Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Selecting all cells in a column between two cells


He did. Given he didn't make any mistakes in expressing what he wanted
to do, I had all the information I needed to provide a very quick
solution, as I posted initially.

Best Regards,

Lars

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Lars Uffmann" wrote in message
...
Darren Ingram wrote:
Thanks for the code but how does the "apple or banana" row number get
calculated when it changes from situation to situation?


Well of course you have to identify your apple and banana cells somehow...
Either you *know* where they are (because of an active selection, or
something else), or you have to locate them, using the Find statement, for
example:

Set rangeApple = ws.Cells.Find("apple", SearchOrder:=xlByRows,
SearchDirection:=xlNext)
Set rangeBanana = ws.Cells.Find("banana", SearchOrder:=xlByRows,
SearchDirection:=xlNext)

Alternatively to ws.Cells you can use ws.Columns(yourColumnIndex) if you
know which column you are searching in.

And the row number does not get calculated, it's a property of a cell
represented in a range - row, column, value and all the other properties
are directly linked in Excel's memory, otherwise Excel wouldn't know where
to store & display a value :)

D10 another week it might be Dxxx....(whatever). How does the code
identify that the curser goes up until it reaches the next filled cell in
column D?


It doesn't - you stated in your original post that:
At all times the cells in the column between both items are blank.

So I showed you how - given you have the 2 cells apple and banana (in a
range item, for example) - to apply the formula to all the cells between
apple and banana *and* the banana cell.
You need to forget about the "cursor" (selection). When you start using
that, you're only going to get in trouble (selection and cursor position
can change with an accidental mouseclick during script execution). Better
to use variables like worksheet and range objects.
You do not need a cursor "movement" at all here - the statement
Range (Cells (row1, column), Cells (row2, column))
returns a collection (similar to an array) of *all* the cells in column
between and including row1 and row2. By modifying the property of such a
range, you modify ALL cells in that range. Much like selecting a big range
manually and pasting some value from clipboard.

When I code the words apple or banana in my code what do I put in their
place. Or are these names just generic and only apply to the bottom
point and top point in the column that I'm running the script on?

They apply to a range that only contains your apple, respectively banana
cell. Which you *could* initialize like I suggested above - but if you
know where they are, don't search for them ;) Only makes your script
slower.

Hope I cleared things up a bit..

Regards,

Lars


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
Selecting specific cells in a column using countif Bob M. Excel Discussion (Misc queries) 1 April 27th 10 07:29 PM
Selecting all the active cells in a named column. Colin Hayes Excel Worksheet Functions 14 October 22nd 09 04:47 AM
How to change shade of cells when selecting multiple cells abrummet Excel Discussion (Misc queries) 3 September 6th 07 11:42 AM
By selecting cells adjacent to cells tally sheet tom Excel Worksheet Functions 2 September 20th 06 07:09 PM
Selecting Column of Visible AutoFiltered Cells. Robert Christie[_3_] Excel Programming 9 January 12th 05 11:15 PM


All times are GMT +1. The time now is 11:14 AM.

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

About Us

"It's about Microsoft Excel"