Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 135
Default Copying a split range

I am trying to use a form to copy the formulas from a named range on one
sheet to a named range on a second sheet. The ranges are split, but they are
the same size and shape. For example range "Main" on Sheet1 is
"A1:A10,D1:D10,G1:G10" and range "Backup" on Sheet2 is also
"A1:A10,D1:D10,G1:G10"

Parts of the range copy correctly, but other parts copy the same formula to
a group of cells. For example, the A1:A10 portion may work correctly, but all
of the cells in the D1:D10 portion get the formula from D1.

Here is the code I am using:
Private Sub cmdNext_Click()
If Me.optBackup.Value = True Then
Sheet1.Unprotect
With Sheet1.Range("Main")
.Formula = Sheet2.Range("Backup").Formula
.Locked = True
End With
Sheet1.Protect
End If
Unload Me
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Copying a split range

Get each of the discontiguous areas separately.

Private Sub cmdNext_Click()
Dim myArea as range
If Me.optBackup.Value = True Then
Sheet1.Unprotect
for each myArea in Sheet1.Range("Main").Areas
with myArea
.Formula = Sheet2.Range(.address).Formula
end with
.Locked = True
next myarea
Sheet1.Protect
End If
Unload Me
End Sub

Horatio J. Bilge, Jr. wrote:

I am trying to use a form to copy the formulas from a named range on one
sheet to a named range on a second sheet. The ranges are split, but they are
the same size and shape. For example range "Main" on Sheet1 is
"A1:A10,D1:D10,G1:G10" and range "Backup" on Sheet2 is also
"A1:A10,D1:D10,G1:G10"

Parts of the range copy correctly, but other parts copy the same formula to
a group of cells. For example, the A1:A10 portion may work correctly, but all
of the cells in the D1:D10 portion get the formula from D1.

Here is the code I am using:
Private Sub cmdNext_Click()
If Me.optBackup.Value = True Then
Sheet1.Unprotect
With Sheet1.Range("Main")
.Formula = Sheet2.Range("Backup").Formula
.Locked = True
End With
Sheet1.Protect
End If
Unload Me
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 135
Default Copying a split range

Thank you. I had to put the .Locked = True inside the With statement, but
otherwise, it worked great!

~ Horatio


"Dave Peterson" wrote:

Get each of the discontiguous areas separately.

Private Sub cmdNext_Click()
Dim myArea as range
If Me.optBackup.Value = True Then
Sheet1.Unprotect
for each myArea in Sheet1.Range("Main").Areas
with myArea
.Formula = Sheet2.Range(.address).Formula
end with
.Locked = True
next myarea
Sheet1.Protect
End If
Unload Me
End Sub

Horatio J. Bilge, Jr. wrote:

I am trying to use a form to copy the formulas from a named range on one
sheet to a named range on a second sheet. The ranges are split, but they are
the same size and shape. For example range "Main" on Sheet1 is
"A1:A10,D1:D10,G1:G10" and range "Backup" on Sheet2 is also
"A1:A10,D1:D10,G1:G10"

Parts of the range copy correctly, but other parts copy the same formula to
a group of cells. For example, the A1:A10 portion may work correctly, but all
of the cells in the D1:D10 portion get the formula from D1.

Here is the code I am using:
Private Sub cmdNext_Click()
If Me.optBackup.Value = True Then
Sheet1.Unprotect
With Sheet1.Range("Main")
.Formula = Sheet2.Range("Backup").Formula
.Locked = True
End With
Sheet1.Protect
End If
Unload Me
End Sub


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Copying a split range

Glad you caught the error.

Horatio J. Bilge, Jr. wrote:

Thank you. I had to put the .Locked = True inside the With statement, but
otherwise, it worked great!

~ Horatio

"Dave Peterson" wrote:

Get each of the discontiguous areas separately.

Private Sub cmdNext_Click()
Dim myArea as range
If Me.optBackup.Value = True Then
Sheet1.Unprotect
for each myArea in Sheet1.Range("Main").Areas
with myArea
.Formula = Sheet2.Range(.address).Formula
end with
.Locked = True
next myarea
Sheet1.Protect
End If
Unload Me
End Sub

Horatio J. Bilge, Jr. wrote:

I am trying to use a form to copy the formulas from a named range on one
sheet to a named range on a second sheet. The ranges are split, but they are
the same size and shape. For example range "Main" on Sheet1 is
"A1:A10,D1:D10,G1:G10" and range "Backup" on Sheet2 is also
"A1:A10,D1:D10,G1:G10"

Parts of the range copy correctly, but other parts copy the same formula to
a group of cells. For example, the A1:A10 portion may work correctly, but all
of the cells in the D1:D10 portion get the formula from D1.

Here is the code I am using:
Private Sub cmdNext_Click()
If Me.optBackup.Value = True Then
Sheet1.Unprotect
With Sheet1.Range("Main")
.Formula = Sheet2.Range("Backup").Formula
.Locked = True
End With
Sheet1.Protect
End If
Unload Me
End Sub


--

Dave Peterson


--

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
Copying Named Range Blinkinhek Excel Worksheet Functions 5 August 29th 08 04:54 PM
DGET Function - using a split criteria range? (Excel 2007) MikeT Excel Worksheet Functions 0 August 11th 08 10:37 PM
Copying to a flexible range johncpa Excel Discussion (Misc queries) 1 February 9th 08 06:04 PM
Copying a Range Peter[_8_] Excel Discussion (Misc queries) 1 December 11th 07 04:14 AM
Copying and pasting from a range John Excel Worksheet Functions 3 June 6th 07 05:22 PM


All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"