View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
L. Howard Kittle L. Howard Kittle is offline
external usenet poster
 
Posts: 698
Default A simple copy problem

Hi Norman,

Okay, took all macros out of the sheet module and moved to a spare
worksheet. The copy macro worked fine. Moved, one by one, macros back into
the sheet module and tested the copy after each and when the one below was
returned the copy problem returned.

But still a puzzle. This routine sets 9 ranges and then determines in which
range the activecell is in and then calls a macro pertinent to that range to
do stuff. If activecell is in "rng5" then it calls "Data5" and it does
stuff to "rng5". After that, a macro "ClearNumbersHrow" is called and it
does essentially the same thing but to a different set of ranges and a third
macro is called doing the same stuff to a third set of ranges.

The "Data1 thru 9" macros are a ...Find n, replace with "" and it's the
same with the other two ClearNumber... macros.

Norman, this is just a SUDOKU puzzle solver I made to test my programming
skills, so it really is not that important. But I do appreciate you
suggestion and am really stumped as to why these routines would flaw the
simple little copy macro.

I appreciate your help, but you must have bigger fish to fry.

Thanks a lot,
Howard

Sub ClearNumbersBox()

Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
Dim rng5 As Range
Dim rng6 As Range
Dim rng7 As Range
Dim rng8 As Range
Dim rng9 As Range

On Error Resume Next
Set rng1 = Intersect(ActiveCell, Range("Data1"))
Set rng2 = Intersect(ActiveCell, Range("Data2"))
Set rng3 = Intersect(ActiveCell, Range("Data3"))
Set rng4 = Intersect(ActiveCell, Range("Data4"))
Set rng5 = Intersect(ActiveCell, Range("Data5"))
Set rng6 = Intersect(ActiveCell, Range("Data6"))
Set rng7 = Intersect(ActiveCell, Range("Data7"))
Set rng8 = Intersect(ActiveCell, Range("Data8"))
Set rng9 = Intersect(ActiveCell, Range("Data9"))

On Error GoTo 0

If Not rng1 Is Nothing Then
Call Data1
ElseIf Not rng2 Is Nothing Then
Call Data2
ElseIf Not rng3 Is Nothing Then
Call Data3
ElseIf Not rng4 Is Nothing Then
Call Data4
ElseIf Not rng5 Is Nothing Then
Call Data5
ElseIf Not rng6 Is Nothing Then
Call Data6
ElseIf Not rng7 Is Nothing Then
Call Data7
ElseIf Not rng8 Is Nothing Then
Call Data8
ElseIf Not rng9 Is Nothing Then
Call Data9
Else
'do nothing
End If

ClearNumbersHrow
End Sub



"L. Howard Kittle" wrote in message
...
Hello Excel users and experts,

Excel 2002 SP3

I am using this incredibly complex copy macro in a worksheet. Took me
weeks to build it...(sarcasm intended!) For a couple weeks it did exactly
what you would expect, copies E2:M10 to E28:M36. No blinks, no jumps, no
nothing, just copies like you would expect at the click of a forms button.

Now, for a reason I cannot fathom, it copies to E28:M36 and that entire
range is selected with E28 the activecell and the sheet has moved down to
show the range!!!

What the h... am I overlooking? I must have my nose too close to my VB
editor to see what must be the obvious!

Sub CopyIt()
Range("E2:M10").Copy Range("E28")
End Sub

Thanks,
Howard