Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to take a group of cells and merge them. I know they will always be
columns B through F, but the row number will vary. I saved the row number in a variable (rownum), but can't figure out how to then select those cells to merge. I have this, but it doesn't work. I would appreciate any help you can give me. Thanks in advance, Dim SelRange As Range Set SelRange = ActiveSheet.ActiveCell.Range(Cells(rownum, 2), Cells(rownnum, 6)) Range(SelRange).Select Selection.Font.Bold = True With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -- Gary "SteveM" wrote in message ... I want to take a group of cells and merge them. I know they will always be columns B through F, but the row number will vary. I saved the row number in a variable (rownum), but can't figure out how to then select those cells to merge. I have this, but it doesn't work. I would appreciate any help you can give me. Thanks in advance, Dim SelRange As Range Set SelRange = ActiveSheet.ActiveCell.Range(Cells(rownum, 2), Cells(rownnum, 6)) Range(SelRange).Select Selection.Font.Bold = True With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() don't have to select them range("A1:c1").MergeCells = true Range(SelRange).MergeCells = true -- Gary "SteveM" wrote in message ... I want to take a group of cells and merge them. I know they will always be columns B through F, but the row number will vary. I saved the row number in a variable (rownum), but can't figure out how to then select those cells to merge. I have this, but it doesn't work. I would appreciate any help you can give me. Thanks in advance, Dim SelRange As Range Set SelRange = ActiveSheet.ActiveCell.Range(Cells(rownum, 2), Cells(rownnum, 6)) Range(SelRange).Select Selection.Font.Bold = True With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. I tried this but got an error for this line:
Set SelRange = ActiveSheet.ActiveCell.Range(Cells(rownum, 2), Cells(rownnum, 6)) But it's closer than I was. Thanks. "Gary Keramidas" wrote: don't have to select them range("A1:c1").MergeCells = true Range(SelRange).MergeCells = true -- Gary "SteveM" wrote in message ... I want to take a group of cells and merge them. I know they will always be columns B through F, but the row number will vary. I saved the row number in a variable (rownum), but can't figure out how to then select those cells to merge. I have this, but it doesn't work. I would appreciate any help you can give me. Thanks in advance, Dim SelRange As Range Set SelRange = ActiveSheet.ActiveCell.Range(Cells(rownum, 2), Cells(rownnum, 6)) Range(SelRange).Select Selection.Font.Bold = True With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Say row1 is the first row and row2 is the last row:
Sub splice_um() Dim r As Range row1 = 3 row2 = 7 Set r = Range("B" & row1 & ":F" & row2) r.MergeCells = True End Sub -- Gary''s Student - gsnu200816 "SteveM" wrote: I want to take a group of cells and merge them. I know they will always be columns B through F, but the row number will vary. I saved the row number in a variable (rownum), but can't figure out how to then select those cells to merge. I have this, but it doesn't work. I would appreciate any help you can give me. Thanks in advance, Dim SelRange As Range Set SelRange = ActiveSheet.ActiveCell.Range(Cells(rownum, 2), Cells(rownnum, 6)) Range(SelRange).Select Selection.Font.Bold = True With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. I had tried concatenating the row number with the B and F, but I
guess I didn't do it correctly. I took your method and did this: Set SelRange = Range("B" & rownum & ":F" & rownum) SelRange.MergeCells = True and it worked like a charm. Thank you very much! "Gary''s Student" wrote: Say row1 is the first row and row2 is the last row: Sub splice_um() Dim r As Range row1 = 3 row2 = 7 Set r = Range("B" & row1 & ":F" & row2) r.MergeCells = True End Sub -- Gary''s Student - gsnu200816 "SteveM" wrote: I want to take a group of cells and merge them. I know they will always be columns B through F, but the row number will vary. I saved the row number in a variable (rownum), but can't figure out how to then select those cells to merge. I have this, but it doesn't work. I would appreciate any help you can give me. Thanks in advance, Dim SelRange As Range Set SelRange = ActiveSheet.ActiveCell.Range(Cells(rownum, 2), Cells(rownnum, 6)) Range(SelRange).Select Selection.Font.Bold = True With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select Merged Cells and Unmerge Spread Merge Data To All Cells | Excel Programming | |||
Mail merge macro: select recipients from Excel during merge | Excel Programming | |||
How do I use For loop to pick different Range of cells to Select & Merge? | Excel Programming | |||
Need to select 4 cells and merge them using Excell 2003 | Excel Programming | |||
Select and merge cells with duplicate values | Excel Programming |