• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Required to run Macro only if d13 has text purchase selected

MurtazaJ

New Member
Hi!

I am totally new in Macros in Excel.

I have an excel sheet where the data of sales and purchase is mention and it has macro which will copy the purchase data to purchase sheet and sales data to sales sheet. but before running the purchase macro i want it should check whether the d3 cell is purchase as value as well sales macro should check if the d3 cell has sales as text.

Please guide as i am totally new to make stock in and out in excel.
 

Attachments

  • FMB STOCK AND SALES (version 1).xlsm
    88.4 KB · Views: 6
It is not really clear what you are after but you have a few options


Code:
Sub Purchase()

If Sheets("PURCHASE").Range("D3").Text <> "Some text" Then Exit Sub

'Put the rest of the code here

End Sub

or



Code:
Sub Purchase()

If Sheets("PURCHASE").Range("D3").Text = "Some text" Then

    Range("D6:D16").Select
    Selection.Copy
    Sheets("PURCHASE").Select
    Range("B4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
    Range("B4").Select
    Application.CutCopyMode = False
    Selection.ListObject.ListRows.Add (1)
    Sheets("HOME").Select
    Range("D6:D15").Select
    Selection.ClearContents
    Range("D3").Select
    Selection.ClearContents

End If

End Sub
'
 
Thanks hui for your reply

I will make you understand in simplest way. I will be using the Home Sheet in which there will be 2 option of Purchase and sales to be entered. I have 2 macro i.e. Purchase macro and sales macro which will copy the data from home sheet and paste in transpose way to respective sheets. i just want when i call macro in home sheet by pressing the Purchase entry it should validate the text d3 as purchase and then only it should run and vice versa for sales.

(it's like if d3 = "purchase" then only purchase macro should run on click of purchase entry clipart)

Hope i should have made you understand my need. Please support and advice.
 
I have given you enough assistance in the above to help you

Please give it a go yourself first
 
Back
Top