Solved

How to insert two pieces of Visual Basic code into the same workbook / worksheet

Posted on 2013-05-21
4
381 Views
Last Modified: 2013-05-21
Hi Guys

I know Im really slow when it comes to things like this as im not a programmer - I just ask you guys for help

I have a spreadsheet and I want to insert two pieces of code (from here actually) - one that auto colours cells when a certain letter is inserted - this is in and working great, but I have another that I need to insert into the same sheet that performs another function.

Can you help

Much appreciated

Jase
0
Comment
Question by:Jase Alexander
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39183950
Just copy and paste the two chunks of code into the same module - one after the other. They can both co-exist in the same module at the same time as long as they don't share the same routine name.

Kevin
0
 

Author Comment

by:Jase Alexander
ID: 39183968
Thanks for the reply

I have two routines which both start with Private Sub Worksheet_Change but when I try and enter them in the same module, it gives me an Ambiguous Name Error or something - is there a way around this?

Cheers
Jase
0
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 39183970
Yes, place the code within the second routine into the first routine:

Private Sub Worksheet_Change(ByVal Target As Range)

' Code from first routine.

' Code from second routine.

End Sub

Kevin
0
 

Author Closing Comment

by:Jase Alexander
ID: 39184037
Fab !!

Thanks for the quick response
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question