Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default referring by index to adjacent cells

Hi,
I need to repeatedly select a cell by its index (e.g. Cells(r,1) with a loop
over r), and merge it with the cell to the right. Could you please tell me
how it can be done? (Can I select the cell, and then expand Selection to the
right?)
Thank you very much!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default referring by index to adjacent cells

Hi
one way:
cells(r,1).resize(1,2).select

--
Regards
Frank Kabel
Frankfurt, Germany


Demyan wrote:
Hi,
I need to repeatedly select a cell by its index (e.g. Cells(r,1) with
a loop over r), and merge it with the cell to the right. Could you
please tell me how it can be done? (Can I select the cell, and then
expand Selection to the right?)
Thank you very much!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default referring by index to adjacent cells

I assumed you meant to iterate through a range of cells
using a loop and to merge each of these cells with the
cell on the right. There is seldom a need to select cells.

Sub MergeCells()
Dim r As Integer
For r = 5 To 10
Cells(r, 1).Resize(1, 2).MergeCells = True
Next r
End Sub

Regards,
Greg


-----Original Message-----
Hi,
I need to repeatedly select a cell by its index (e.g.

Cells(r,1) with a loop
over r), and merge it with the cell to the right. Could

you please tell me
how it can be done? (Can I select the cell, and then

expand Selection to the
right?)
Thank you very much!
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default referring by index to adjacent cells

Use the Range selection and cells to select the anchor and the range extent.
So......

Range(Cells(r, c1), Cells(r, c2)).Select

where c1 = first column and c2 increments to extend range to the right.

Cheers
Nigel

"Demyan" wrote in message
...
Hi,
I need to repeatedly select a cell by its index (e.g. Cells(r,1) with a

loop
over r), and merge it with the cell to the right. Could you please tell me
how it can be done? (Can I select the cell, and then expand Selection to

the
right?)
Thank you very much!



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
Add cells on two adjacent rows but non-adjacent columns Eve Excel Worksheet Functions 14 October 20th 09 02:32 AM
IF Formula referring to 2 cells Marilyn Excel Discussion (Misc queries) 1 March 22nd 09 08:45 PM
Referring to Cells PeterM Excel Discussion (Misc queries) 4 May 30th 08 02:37 PM
Sort a list with cells referring to others cells Friis(DK) Excel Discussion (Misc queries) 6 February 24th 07 03:56 AM
referring to other cells with formulas ALex Excel Worksheet Functions 1 April 11th 05 05:14 PM


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