Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Problem copying name range

I have the following section of code which is intended to copy a named range
to A4 if the content of C3 is anything except "TWAIN i/f". Didapikit is a
named range (1 row, 5 columns) on another sheet in the workbook and if I
place the line elsewhere in the code (ie not in this subroutine) it will
copy the range.

The worksheet is protected at the point of entry into this subroutine, but
it doesn't make any difference if I uncomment the protect/unprotect lines.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
' Worksheets("Dental").Unprotect
On Error GoTo sub_exit
If Not Intersect(Target, Worksheets("Dental").Range("C3")) Is Nothing
Then
With Target
If .Value = "TWAIN i/f" Then
With Range("A4:E4")
.ClearContents '
.ClearComments
.Borders.LineStyle = xlNone
.UnMerge
.Locked = True
End With
Else
Didapikit.Copy (Worksheets("Dental").Range("A4"))
End If
End With
End If
sub_exit:
Application.EnableEvents = True
' Worksheets("Dental").Protect
End Sub

Basically, the "If" works, but the "Else" doesn't. Any ideas?

--
Ian
--


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Problem copying name range


The worksheet is protected at the point of entry into this subroutine, but
it doesn't make any difference if I uncomment the protect/unprotect lines.


Sorry, I was wrong about this. If the sheet is protected, the "If" doesn't
work either. The fact remains that the "copy" line doesn't work whether the
sheet is protected or not.

--
Ian
--


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Problem copying name range

Remember that the name of a range and a range variable are two different
things. Your code will work if Didapikit is a genuine range:

Dim Didapikit as Range
Set Didapikit=Range("A1:Z100")
Didapikit.Copy some_place_else


If, however, Didapikit is a Defined Name, then

Range("Didapikit").Copy some_where_else

should be used.
--
Gary''s Student - gsnu200905


"IanC" wrote:

I have the following section of code which is intended to copy a named range
to A4 if the content of C3 is anything except "TWAIN i/f". Didapikit is a
named range (1 row, 5 columns) on another sheet in the workbook and if I
place the line elsewhere in the code (ie not in this subroutine) it will
copy the range.

The worksheet is protected at the point of entry into this subroutine, but
it doesn't make any difference if I uncomment the protect/unprotect lines.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
' Worksheets("Dental").Unprotect
On Error GoTo sub_exit
If Not Intersect(Target, Worksheets("Dental").Range("C3")) Is Nothing
Then
With Target
If .Value = "TWAIN i/f" Then
With Range("A4:E4")
.ClearContents '
.ClearComments
.Borders.LineStyle = xlNone
.UnMerge
.Locked = True
End With
Else
Didapikit.Copy (Worksheets("Dental").Range("A4"))
End If
End With
End If
sub_exit:
Application.EnableEvents = True
' Worksheets("Dental").Protect
End Sub

Basically, the "If" works, but the "Else" doesn't. Any ideas?

--
Ian
--



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Problem copying name range

Sorted thanks. The subroutine didn't recognise the named range so I had to
"Set" it at the beginning of the routine.

--
Ian
--


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
Newbie: VBA problem when copying cell range Frank Excel Programming 1 August 25th 06 01:33 PM
Problem copying a range to another file Bob Lehrer Excel Programming 5 March 20th 06 12:07 PM
copying and pasting range problem Henrik Excel Programming 1 November 15th 05 01:49 PM
Problem copying formula to range of cells Bob DePass Setting up and Configuration of Excel 0 July 22nd 05 02:09 AM
Problem copying a range to a different workbook [email protected] Excel Programming 3 December 8th 04 01:43 AM


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