Make a Macro Conditional

esc952

New Member
Joined
Dec 3, 2015
Messages
4
I have a multi-sheet inventory spreadsheet (Excel 2013), where each of 6 departments uses a form to track/manage parts. I've created a button on each sheet that allows them to copy particular fields to a Purchasing List Sheet. What I want to do is make that macro conditional such that:

- IF E25=0, then proceed...else give the user a message that the record is not closed
- IF E22>0, copy C22 to the Purchasing Sheet, else IF E21>0 copy C21 to the Purchasing Sheet

- Continue the remainder of the cell copies (this portion is already working)

Can anyone help me code that condition to add into my "CopytoPurchLog" macro (which was recorded, not coded since it has been years since I did any real coding)?

Thanks a ton in advance.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Thanks Smitty...below is the code (hope that is the correct "code posting etiquette")



Sub CopytoPurchLog()
'
' CopytoPurchLog Macro
' Copies Closed Inventory to Purchasing Log
'


'
Range("C19").Select
Selection.Copy
Windows("Inventory.xlsm:2").Activate
ActiveSheet.Paste
Windows("Inventory.xlsm:1").Activate
Range("C21").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("D3").Select
ActiveSheet.Paste
Windows("Inventory.xlsm:1").Activate
Range("C3").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("G3").Select
ActiveSheet.Paste
Windows("Inventory.xlsm:1").Activate
Range("H3").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("H3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Inventory.xlsm:1").Activate
Range("C5").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("I3").Select
ActiveSheet.Paste
Windows("Inventory.xlsm:1").Activate
Range("H6").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("J3").Select
ActiveSheet.Paste
Windows("Inventory.xlsm:1").Activate
Range("H16").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("K3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("L3").Select
Windows("Inventory.xlsm:1").Activate
Range("B16").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Inventory.xlsm:1").Activate
Range("E24").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("M3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Inventory.xlsm:1").Activate
Range("I24").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Inventory.xlsm:2").Activate
Range("N3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3").Select
Application.CutCopyMode = False
Selection.Copy
Range("A4").Select
ActiveSheet.Paste
Range("C3").Select
Application.CutCopyMode = False
Selection.Copy
Range("C4").Select
ActiveSheet.Paste
Range("E3").Select
Application.CutCopyMode = False
Selection.Copy
Range("E4").Select
ActiveSheet.Paste
Range("F3").Select
Application.CutCopyMode = False
Selection.Copy
Range("F4").Select
ActiveSheet.Paste
Range("O3").Select
Application.CutCopyMode = False
Selection.Copy
Range("O4").Select
ActiveSheet.Paste
Windows("Inventory.xlsm:1").Activate
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,938
Members
449,197
Latest member
k_bs

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
Back
Top