LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
carl
 
Posts: n/a
Default Macro / Compile Error / Duplicate Declaration

I am trying to modify my macro to perform the same operations twice - I am
trying to do this by copying/paste the macro and making some changes to the
copied macro. When I try and run the macro, I get a compiler error "Duplicate
Declaration In Current Scope" - the macro stops at the line marketed with ***
below.

Is there a way to modify the macro to get it to work ?

Thank you in advance

'find engine 2 part A
Sheets("A").Select
Dim rng As Range
Set rng = _
Columns(7).Find(What:="1", After:=Cells(Rows.Count, "g"), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)


If Not rng Is Nothing Then
rng.Select
Else
MsgBox "1 not found"
End If

'cut engine 2
' Range("G12816").Select (old code)
rng.Offset(1, 0).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Sheets("2").Select
Range("A1").Select
ActiveSheet.Paste

Sheets("A").Select
Range("H1:I1").Select
Selection.Copy
Sheets("2").Select
Range("H1").Select
ActiveSheet.Paste
Range("F1:G1").Select
Range("G1").Activate
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("A").Select
Range("F1:G1").Select
Range("G1").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Sheets("A").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A1:I11496").Select
Selection.Cut
Sheets("1").Select
Range("A1").Select
ActiveSheet.Paste

'find engine 2 part B
Sheets("B").Select
**** Dim rng As Range ****
Set rng = _
Columns(7).Find(What:="1", After:=Cells(Rows.Count, "g"), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False)


If Not rng Is Nothing Then
rng.Select
Else
MsgBox "1 not found"
End If

'cut engine 2
' Range("G12816").Select (old code)
rng.Offset(1, 0).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Sheets("2").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste.


 
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
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM


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