Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default cell selection, merging.....

Ok, As stated in another post, I'm trying to make a macro for a selection of
cells based on a criteria.
In running it through, I'm finding that it selects increasingly larger cell
groupings.
I tried setting the variable to nothing, so as to "reset" it, for the
purpose of only grabbing the cells around which my criteria exists.

My core code is:

For Each rcell2 In Selection
If rcell2.Borders(xlEdgeBottom).LineStyle = xlSolid Then
ActiveSheet.Range(rcell1, rcell2).Select
With Selection
.Merge
.VerticalAlignment = xlCenter
.HorizontalAlignment = xlCenter
End With
'Set rcell1 = Nothing
'Set rcell2 = Nothing
ActiveCell.Offset(1, 0).Select
'end if
End If
Next rcell2

If I use the set ... = nothing, it emtpies the variable, resulting in my
outermost if test to fail-- I get an object or with block not set error.

So, I need some code to empty the buffer of the value for my rcell1
variable-- so I can still retain its being a selection, but not have it
remember the original cell location.
What code would I use to accomplish this?

Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default cell selection, merging.....

First, I would drop the .select's

For Each rcell2 In Selection
If rcell2.Borders(xlEdgeBottom).LineStyle = xlSolid Then
with ActiveSheet.Range(rcell1, rcell2)
.Merge
.VerticalAlignment = xlCenter
.HorizontalAlignment = xlCenter
End With
'then maybe reset the rcell1
'maybe to the cell below the last rcell2
set rcell1 = rcell2.offset(0,1)
set rcell2 = nothing
end if
Next rcell2

But this is just a guess. I really don't know what rcell1 is used for.

Steve wrote:

Ok, As stated in another post, I'm trying to make a macro for a selection of
cells based on a criteria.
In running it through, I'm finding that it selects increasingly larger cell
groupings.
I tried setting the variable to nothing, so as to "reset" it, for the
purpose of only grabbing the cells around which my criteria exists.

My core code is:

For Each rcell2 In Selection
If rcell2.Borders(xlEdgeBottom).LineStyle = xlSolid Then
ActiveSheet.Range(rcell1, rcell2).Select
With Selection
.Merge
.VerticalAlignment = xlCenter
.HorizontalAlignment = xlCenter
End With
'Set rcell1 = Nothing
'Set rcell2 = Nothing
ActiveCell.Offset(1, 0).Select
'end if
End If
Next rcell2

If I use the set ... = nothing, it emtpies the variable, resulting in my
outermost if test to fail-- I get an object or with block not set error.

So, I need some code to empty the buffer of the value for my rcell1
variable-- so I can still retain its being a selection, but not have it
remember the original cell location.
What code would I use to accomplish this?

Thank you.


--

Dave Peterson
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
Cell Merging Sudipta Sen[_2_] Excel Discussion (Misc queries) 1 November 23rd 09 06:35 AM
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Cell Merging Issue IainB Excel Discussion (Misc queries) 3 July 13th 08 06:30 PM
How to create a selection list then display the selection in a cell [email protected] Excel Programming 0 August 1st 07 03:01 PM
Change from Column Selection to Cell Selection Lil Pun[_16_] Excel Programming 4 June 16th 06 10:38 PM


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