Orange_Wed
10-30-2008, 09:49 AM
Hello Folks,
I am having an issue with pasting data from another workbook into a workbook with merged cells. The code I've thrown together works fine in Excel 2003 & 2007, but two of the systems in our office are still running 2000 builds.
The merged cells are necessary for esthetic reasons, as well as the simple fact that they keep the folks who don't quite know a mouse from an optical drive from asking me why they can't enter data directly into my protected headings and labels.
Is there any way of pasting data into merged cells using a macro in 2000 that anyone could fill me in on? It would be nice if it were forward-compatable with 2003 and 2007, as this sheet is to be on a shared drive and accessable by all the office staff.
Here is a sample of the code in the sheet containing the data to be copied:
Sub SwitchToReport() 'pasted into ThisWorkbook in file Employee Records.xls
ActiveCell.Copy
Workbooks("copy of combined.xls").Activate
ActiveCell.PasteSpecial xlPasteValues 'Gives a generic "400" error here
Workbooks("Employee Record.xls").Close SaveChanges:=False
End Sub
For testing purposes, I'll include a copy of the right-click menu modification I took directly from the Excel help files and modified for my purposes:
Private Sub Worksheet_BeforeRightClick(ByVal target As Range, _
Cancel As Boolean)
For Each icbc In Application.CommandBars("cell").Controls
If icbc.Tag = "brccm" Then icbc.Delete
Next icbc
If Not Application.Intersect(target, Me.Range("B:B")) Is Nothing Then
With Application.CommandBars("cell").Controls _
.Add(Type:=msoControlButton, before:=6, _
temporary:=True)
.Caption = "<---Insert Name--->"
.OnAction = "Thisworkbook.SwitchToReport"
.Tag = "brccm"
End With
End If
End Sub
I've stripped this aspect of the project down to the bare minimum of code and even combined the sheets of two workbooks to see if it was corruption in the original file. Narrowed it down to the fact that one sheet has merged cells, and this is where the code fails. I have tried the ActiveSheet.Paste method without sucess, as well.
I've attached a stripped down version of the main sheets for your perusal.
If anyone could give me some pointers, it would be most appreciated. These sheets have been adapted from a paper-only format, and I want to stick as close to the original style as is possible to reduce the learning curve.
Thanks in advance,
Wednesday
I am having an issue with pasting data from another workbook into a workbook with merged cells. The code I've thrown together works fine in Excel 2003 & 2007, but two of the systems in our office are still running 2000 builds.
The merged cells are necessary for esthetic reasons, as well as the simple fact that they keep the folks who don't quite know a mouse from an optical drive from asking me why they can't enter data directly into my protected headings and labels.
Is there any way of pasting data into merged cells using a macro in 2000 that anyone could fill me in on? It would be nice if it were forward-compatable with 2003 and 2007, as this sheet is to be on a shared drive and accessable by all the office staff.
Here is a sample of the code in the sheet containing the data to be copied:
Sub SwitchToReport() 'pasted into ThisWorkbook in file Employee Records.xls
ActiveCell.Copy
Workbooks("copy of combined.xls").Activate
ActiveCell.PasteSpecial xlPasteValues 'Gives a generic "400" error here
Workbooks("Employee Record.xls").Close SaveChanges:=False
End Sub
For testing purposes, I'll include a copy of the right-click menu modification I took directly from the Excel help files and modified for my purposes:
Private Sub Worksheet_BeforeRightClick(ByVal target As Range, _
Cancel As Boolean)
For Each icbc In Application.CommandBars("cell").Controls
If icbc.Tag = "brccm" Then icbc.Delete
Next icbc
If Not Application.Intersect(target, Me.Range("B:B")) Is Nothing Then
With Application.CommandBars("cell").Controls _
.Add(Type:=msoControlButton, before:=6, _
temporary:=True)
.Caption = "<---Insert Name--->"
.OnAction = "Thisworkbook.SwitchToReport"
.Tag = "brccm"
End With
End If
End Sub
I've stripped this aspect of the project down to the bare minimum of code and even combined the sheets of two workbooks to see if it was corruption in the original file. Narrowed it down to the fact that one sheet has merged cells, and this is where the code fails. I have tried the ActiveSheet.Paste method without sucess, as well.
I've attached a stripped down version of the main sheets for your perusal.
If anyone could give me some pointers, it would be most appreciated. These sheets have been adapted from a paper-only format, and I want to stick as close to the original style as is possible to reduce the learning curve.
Thanks in advance,
Wednesday