Loading...

excel-macros@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

RE: $$Excel-Macros$$ Parsing a range to an array Dave Bonallack Thu Oct 28 02:00:18 2010

Hi,
You can test for a non-contiguous selection with the following line of code:
A = Selection.Areas.Count
 
Use this in an If statement - eg
If Selection.Areas.Count > 1 then msgbox "You can't use non-contiguous cells.": 
Exit Sub
 
Hope this helps.
Regards - Dave.
 
 
 

 
> Date: Thu, 28 Oct 2010 00:28:29 -0700
> Subject: $$Excel-Macros$$ Parsing a range to an array
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> 
> Hi Everyone,
> 
> I am building a series of wizards for handling some internal processes
> at my office. We are extracting data from from '3rd party' data
> sources into excel worksheets. To further process this data by hand is
> slow, so I was asked to write a few macros etc to speed things up. The
> issue I am facing is occuring when the user selects the specific cells
> they want to use for a particular wizard / process.
> 
> When the user selects contiguous cells, cells that are next to each
> other, then all is fine when using the processes. I am letting the
> user choose the cells via the ref object on a user form. The user
> sometimes chooses cells that are not next to each other, cells in the
> same column but not right next to each other for example. This causes
> me a problem in handling the data and breaks my code. I am grabbing
> the data as follows:
> 
> varXRange() = Range(refXRange)
> 
> This normally retuns me an array in R1C1 type 'layout', and is
> extremely useful for processing large volumes of data at speed. What I
> am trying to do is to find a way to achieve the same, but with non
> contiguous ranges. I was thinking of simply searching the string that
> the ref object returns for commas, then process each chunk separately
> adding it to an array, but was wondering if someone already has an
> approach to solving this?
> 
> Any thoughts would be appreciated
> 
> Cheers
> 
> The Frog
> 
> -- 
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links : 
> http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
> 
> To post to this group, send email to [EMAIL PROTECTED]
> 
> <><><><><><><><><><><><><><><><><><><><><><>
> Like our page on facebook , Just follow below link
> http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts
                                          

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to [EMAIL PROTECTED]

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts