Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How do I use For loop to pick different Range of cells to Select & Merge?

Hi!
I'm trying to loop through Ranges of Cells to select & merge them
together.
I can do this by hand, and I can do this if I hardcode the cell
row&column values.

BUT, I can't seem to figure out how to do this programatically!

Thanks!
David

-----------------sample code--------------------

For datastartrow = 5 to 50
rem datastartrow is the row I'm on

ActiveSheet.Range("B13:H13").Select
ActiveSheet.Range("B13:H13").Merge
rem == Hardcoding works, but... I need to loop through the rows....

rem == HOW DO I CHANGE this to something I can loop through?
rem == eg. this doesn't work for some reason:
rem == ActiveSheet.Range(Cells(datastartrow, 2),
Cells(datastartrow, 9)).Select
rem == ActiveSheet.Range(Cells(datastartrow, 2),
Cells(datastartrow, 9)).Merge

With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With

Next i

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How do I use For loop to pick different Range of cells to Select & Merge?

activesheet.cells(myrow,"B").resize(1,7).merge

Thanks for the quick answer! That helped me after days of
searching for an answer!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I use For loop to pick different Range of cells to Select &Merge?

I like the non-looping way better!

wrote:

activesheet.cells(myrow,"B").resize(1,7).merge


Thanks for the quick answer! That helped me after days of
searching for an answer!!


--

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
How do i pick up a list of invoice numbers on a range of cells oasalako1 Excel Discussion (Misc queries) 3 October 18th 07 11:53 AM
loop through cells in a range and pick up corresponding cell values in another range [email protected] Excel Programming 9 October 19th 06 05:11 AM
Specifying Range.Select in a loop MervB Excel Programming 5 November 10th 05 12:41 AM
A loop to merge cells based on a value tschultz[_3_] Excel Programming 0 August 24th 05 07:50 PM
How do I Pick a cell with highest value from a range of cells? Chappy1648 Excel Worksheet Functions 1 May 19th 05 01:55 PM


All times are GMT +1. The time now is 01:02 AM.

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"