Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-21
4
Medium Priority
?
386 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 2000 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

670 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