Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default combining macros - compile error: duplicate declaration in current scope

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default combining macros - compile error: duplicate declaration in current scope

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" wrote in message
ups.com...
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
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
Duplicate declaration in scope Hebs Excel Programming 2 January 10th 12 07:48 PM
Running macros it returns compile error in hidden module [email protected] Excel Programming 1 December 1st 06 04:04 PM
Macro / Compile Error / Duplicate Declaration carl Excel Worksheet Functions 1 June 29th 05 08:55 PM
duplicate declaration [email protected] Excel Programming 1 March 1st 05 02:03 AM
Compile error for macros MICHAEL Excel Programming 2 June 18th 04 12:12 AM


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