PC Review


Reply
Thread Tools Rate Thread

combining macros - compile error: duplicate declaration in current scope

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      9th Dec 2006
I have a problem where I've recorded many macros within a workbook and
I am trying to consolidate them so the workbook wont be so large and
have so many macros.
Instead of doing it this way:

Sub MainMacro()
run macro 1
run macro 2
run macro 3

End Sub

I began actually copyingt the codes and combining them. The problem I
get is when I run the final macro, I have to go back and put a number
in front of some commands like "Rng" & "String" to avoid the "compile
error: duplicate declaration in current scope."

Example code:

Dim Rng As Range, cell As Range
Dim s As String, s1 As String
Dim sChr As String, i As Long
Set Rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
For Each cell In Rng

Any suggestions on combining macros? Or to avoid this particular error?
I sure hate going back trying to number each to separate them.

Thanx.

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      9th Dec 2006
The workbook may be smaller, but the code will be a lot more unwieldy.

I would suggets you revert to your multiple macros.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a problem where I've recorded many macros within a workbook and
> I am trying to consolidate them so the workbook wont be so large and
> have so many macros.
> Instead of doing it this way:
>
> Sub MainMacro()
> run macro 1
> run macro 2
> run macro 3
>
> End Sub
>
> I began actually copyingt the codes and combining them. The problem I
> get is when I run the final macro, I have to go back and put a number
> in front of some commands like "Rng" & "String" to avoid the "compile
> error: duplicate declaration in current scope."
>
> Example code:
>
> Dim Rng As Range, cell As Range
> Dim s As String, s1 As String
> Dim sChr As String, i As Long
> Set Rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
> For Each cell In Rng
>
> Any suggestions on combining macros? Or to avoid this particular error?
> I sure hate going back trying to number each to separate them.
>
> Thanx.
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Duplicate declaration in current scope" during edit and continue Greg Lovern Microsoft Excel Programming 1 7th Apr 2011 10:33 PM
Process steps to compile current VBA macros into a DLL or COM Addin EagleOne@discussions.microsoft.com Microsoft Excel Programming 1 20th May 2009 01:28 AM
Macro / Compile Error / Duplicate Declaration =?Utf-8?B?Y2FybA==?= Microsoft Excel Worksheet Functions 1 29th Jun 2005 08:55 PM
VS 2003 Designer bug? -- Duplicate declaration error Deanna Delapasse Microsoft Dot NET Framework Forms 1 5th Aug 2004 03:00 AM
Declaration Scope and Efficiency JimM Microsoft VB .NET 3 30th Oct 2003 05:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:37 PM.