#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Merge cells

I'm updating an excel spreadsheet from Access 2000 and is
trying to format and merge the header across columns.
Whenever the mergecells property is encountered the
message "The selection contains multiple data values.
Merge into cells will keep the upper-left most data only".
Following is a sample of the code: Is there a more
efficient way to do this?

Set oRange = oSheet.Range("b1:d1")
With oRange
.Value = "Negotiated Current"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With

Set oRange = oSheet.Range("e1:g1")
With oRange
.Value = "Actual Current"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With

Set oRange = oSheet.Range("h1:j1")
With oRange
.Value = "Negotiated ITD"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With

Set oRange = oSheet.Range("k1:m1")
With oRange
.Value = "Actual ITD"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default Merge cells

Try the following:

Sub FormatHeadings()
Dim oRange As Range, oSheet As Worksheet
Dim i As Integer, HeadingArr As Variant

Set oSheet = ActiveSheet
HeadingArr = Array("Negotiated Current", _
"Actual Current","Negotiated ITD", "Actual ITD")

For i = 2 To 11 Step 3
Set oRange = oSheet.Range(Cells(1, i), Cells(1, i + 2))
With oRange
.MergeCells = True
.Value = HeadingArr(Int((i + 1) / 3))
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With
Next

End Sub

Regards,
Greg

-----Original Message-----
I'm updating an excel spreadsheet from Access 2000 and is
trying to format and merge the header across columns.
Whenever the mergecells property is encountered the
message "The selection contains multiple data values.
Merge into cells will keep the upper-left most data only".
Following is a sample of the code: Is there a more
efficient way to do this?

Set oRange = oSheet.Range("b1:d1")
With oRange
.Value = "Negotiated Current"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With

Set oRange = oSheet.Range("e1:g1")
With oRange
.Value = "Actual Current"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With

Set oRange = oSheet.Range("h1:j1")
With oRange
.Value = "Negotiated ITD"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With

Set oRange = oSheet.Range("k1:m1")
With oRange
.Value = "Actual ITD"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default Merge cells

I forgot the Option Base 1 declartion at the top of the
module. This is twice now. Sorry, I'm just not a
meticulous person.


Regards,
Greg


-----Original Message-----
Try the following:

Sub FormatHeadings()
Dim oRange As Range, oSheet As Worksheet
Dim i As Integer, HeadingArr As Variant

Set oSheet = ActiveSheet
HeadingArr = Array("Negotiated Current", _
"Actual Current","Negotiated ITD", "Actual ITD")

For i = 2 To 11 Step 3
Set oRange = oSheet.Range(Cells(1, i), Cells(1, i +

2))
With oRange
.MergeCells = True
.Value = HeadingArr(Int((i + 1) / 3))
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With
Next

End Sub

Regards,
Greg

-----Original Message-----
I'm updating an excel spreadsheet from Access 2000 and

is
trying to format and merge the header across columns.
Whenever the mergecells property is encountered the
message "The selection contains multiple data values.
Merge into cells will keep the upper-left most data

only".
Following is a sample of the code: Is there a more
efficient way to do this?

Set oRange = oSheet.Range("b1:d1")
With oRange
.Value = "Negotiated Current"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With

Set oRange = oSheet.Range("e1:g1")
With oRange
.Value = "Actual Current"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With

Set oRange = oSheet.Range("h1:j1")
With oRange
.Value = "Negotiated ITD"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With

Set oRange = oSheet.Range("k1:m1")
With oRange
.Value = "Actual ITD"
.MergeCells = True
.HorizontalAlignment = xlCenter
.Font.Bold = True
end With


.

.

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
Automatically merge mulitiple cells to one cells Edward Wang Excel Worksheet Functions 5 September 15th 09 07:56 PM
how do I merge cells into one then delete the original cells? LLR Excel Worksheet Functions 2 March 7th 08 10:59 PM
Merge Cells Aaron Excel Discussion (Misc queries) 1 November 15th 06 09:38 PM
merge two cells Pam Coleman Excel Discussion (Misc queries) 6 April 22nd 06 02:39 PM
How do I merge cells in Excel, like just 2 cells to make one big . chattacat Excel Discussion (Misc queries) 2 January 19th 05 04:25 PM


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