Automatically run vba if cell condition is met

AawwYeahh

New Member
Joined
Aug 10, 2017
Messages
7
Ok so I am currently working on a more user friendly template for invoicing. I have a data validation list to choose from multiple titles and have modified worksheet to act accordingly when "topic" is picked (IE invoice, Service, etc) my problem is I need different cells (all located in same space) with different formulas. I tried writing in formula to replace if condition is met but I lose cell formatting etc. I have recorded 3 macros but am wondering how to execute them without "pulling the trigger" of clicking on control button. And these are 3 separate macros, seem inelegant and messy. I am hoping someone has a better solution.
This is the default page layout (Macro 1)
Sub Macro1()
'
' Macro1 Macro
'

' Sheets('Layout") .Select
Range("A2:O11").Select
Selection.Copy
Sheets("INVOICE").Select
Range("A16:O25").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub

Macro 2 (for Service)
Sheets('Layout").Select
Range("B14:O23").Select
Selection.Copy
Sheets("INVOICE").Select
Range("A16:O25").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Macro 3 (for construction)
Sheets('Layout").Select
Range("A26:O35").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("INVOICE").Select
Range("A16:O25").Select
ActiveSheet.Paste
End Sub
 

AawwYeahh

New Member
Joined
Aug 10, 2017
Messages
7
VBA Code:
Sub Protect()
Sheets("sheet1").Protect Password:="asdf"
End Sub

Sub Unprotect()
Sheets("sheet1").Unprotect Password:="asdf"
End Sub

Use as per your needs.
Again THANK YOU
Everything is working great!
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Watch MrExcel Video

Forum statistics

Threads
1,126,996
Messages
5,622,076
Members
415,875
Latest member
Tarali

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top