SOLVED

Excel formula combinations

%3CLINGO-SUB%20id%3D%22lingo-sub-1764870%22%20slang%3D%22en-US%22%3EExcel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1764870%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20I%20have%20a%20workbook%20with%20two%20worksheets.%20First%20worksheet%20called%20Prices%2C%20master%20list%20of%20products%20and%20prices%20that%20changes%20any%20time.%20Second%20sheet%20called%20January%20contains%20quotes%2C%20purchase%20orders%2C%20purchase%20requests%20or%20invoices.%20In%20January%20worksheet%20there%20is%20drop%20down%20lists%20each%20row%20its%20own%20list%20under%20Product%20Description%20column.%20Next%20to%20Product%20Description%20is%20Price%20column%20for%20each%20selected%20product.%20Price%20cell%20i%20use%20vlookup%20to%20retrieve%20the%20price%20of%20the%20selected%20product%20which%20works%20fine.%20But%20now%20when%20the%20price%20of%20a%20product%20in%20Prices%20worksheet%20is%20changed%20all%20the%20products%20in%20history%20business%20of%20all%20that%20products%20changes!!!%20How%20can%20i%20resolve%20that%20problem%20that%20once%20a%20product%20in%20a%20cell%20has%20been%20selected%20and%20the%20price%20retrieved%20that%20that%20price%20never%20changes%20ever%3F%3F%3F%3F%3F%3F%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EThank%20You%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1764870%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1765088%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1765088%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F826237%22%20target%3D%22_blank%22%3E%40kobus1305%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfraid%20that%20doesn't%20work%20such%20way%2C%20Excel%20doesn't%20keep%20the%20history.%20As%20variant%20you%20may%20complicate%20the%20logic%20a%20bit%20keeping%20not%20only%20the%20price%20for%20the%20product%2C%20but%20also%20dates%20when%20the%20new%20price%20was%20assigned.%20With%20that%20you%20may%20check%20in%20which%20date%20range%20the%20invoice%20is%20and%20pick-up%20the%20proper%20price%20based%20both%20on%20product%20and%20date.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1765209%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1765209%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F826237%22%20target%3D%22_blank%22%3E%40kobus1305%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BOnce%20VLookup%20formula%20returns%20a%20price%20for%20any%20product%2C%20if%26nbsp%3B%20you%20copy%20the%20formula%20cell%20and%20paste%20it%20back%20as%20a%20Values%2C%20that%20price%20cell%20is%20no%20longer%20connected%20to%20the%20first%20worksheet%20so%20any%20change%20in%20price%20will%20not%20affect%20it.%20Doing%20this%20manually%20would%20be%20a%20cumbersome%20task%20so%20instead%20of%20using%20VLookup%2C%20you%20may%20use%20VBA%20to%20get%20the%20price%20of%20a%20product%20from%20the%20first%20worksheet%20as%20a%20value%20only%2C%20that%20would%20resolve%20your%20issue.%3C%2FP%3E%3CP%3EYou%20may%20consider%20a%20Change%20Event%20code%20on%20second%20worksheet%20so%20that%20once%20you%20select%20a%20Product%20from%20the%20drop%20down%20in%20the%20product%20column%2C%20the%20corresponding%20price%20column%20is%20automatically%20populated%20with%20the%20selected%20product's%20price%20and%20you%20will%20end%20up%20having%20no%20formula%20in%20the%20price%20column.%20Sounds%20good%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1765291%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1765291%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20so%20much%20sounds%20like%20a%20problem%20solver.%20Can%20i%20pick%20your%20brain%20some%20more%20i%20am%20not%20so%20fimiliar%20with%20exactly%20what%20Change%20Event%20code%20consists%20of%20and%20the%20implementation%20thereof.%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1765345%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1765345%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BThank%20you%20for%20your%20response.%20Actual%20fact%20i%20only%20want%20to%20keep%20the%20price%20on%20the%20January%20worksheet%20for%20each%20selected%20product%20price%20either%20quotes%2C%20purchase%20orders%2C%20purchase%20requests%20or%20invoices%20static%20the%20date%20of%20each%20business%20is%20linked%20from%20another%20workbook%20like%20Date%2C%20Validity%20date%2C%20Company%2C%20Responsible%20person%2C%20Company%20Address%2C%20Cell%20Phone%20and%20Responsible%20Person%20Completing%20the%20form.%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EThank%20You%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1765460%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1765460%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F826237%22%20target%3D%22_blank%22%3E%40kobus1305%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EVBA%20solution%20would%20be%20specific%20to%20the%20layout%20of%20your%20data%20on%20both%20the%20sheets.%3C%2FP%3E%3CP%3EIf%20you%20share%20your%20file%2C%20I%20can%20build%20a%20solution%20for%20you.%3C%2FP%3E%3CP%3EIf%20your%20file%20contains%20private%20data%2C%20save%20your%20file%20to%20either%20One%20Drive%20or%20Google%20Drive%20and%20share%20the%20link%20with%20me%20in%20a%20private%20message.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOR%20share%20a%20sample%20file%20after%20removing%20any%20confidential%20data%20which%20has%20the%20layout%20as%20same%20as%20of%20your%20original%20file%2C%20I%20will%20build%20the%20solution%20in%20the%20sample%20file%20and%20let%20you%20know%20how%20you%20can%20implement%20the%20solution%20in%20your%20original%20file%20and%20how%20to%20tweak%20the%20code%20if%20required.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1765762%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1765762%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20be%20so%20thankfull%20no%20private%20info%20just%20data%20referring%20to%20no%20one%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fonedrive.live.com%2Fedit.aspx%3Fcid%3D58b872a7ef66745e%26amp%3Bpage%3Dview%26amp%3Bresid%3D58B872A7EF66745E!110%26amp%3BparId%3D58B872A7EF66745E!101%26amp%3Bapp%3DExcel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fonedrive.live.com%2Fedit.aspx%3Fcid%3D58b872a7ef66745e%26amp%3Bpage%3Dview%26amp%3Bresid%3D58B872A7EF66745E!110%26amp%3BparId%3D58B872A7EF66745E!101%26amp%3Bapp%3DExcel%3C%2FA%3E.%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EThank%20You%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1766088%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1766088%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F826237%22%20target%3D%22_blank%22%3E%40kobus1305%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20opened%20the%20link%20you%20provided%2C%20all%20it%20says%20is%20this...%3C%2FP%3E%3CP%3E%3CEM%3E%22This%20item%20might%20not%20exist%20or%20is%20no%20longer%20available%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20may%20upload%20the%20file%20here%20itself.%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1766381%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1766381%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20just%20opened%20it%20using%20the%20same%20link%20i%20have%20send%20you!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1766397%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1766397%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F826237%22%20target%3D%22_blank%22%3E%40kobus1305%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20i%20saved%20it%20again%20lets%20try%20this%20time!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fonedrive.live.com%2Fedit.aspx%3Fcid%3D58b872a7ef66745e%26amp%3Bpage%3Dview%26amp%3Bresid%3D58B872A7EF66745E!113%26amp%3BparId%3D58B872A7EF66745E!101%26amp%3Bapp%3DExcel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fonedrive.live.com%2Fedit.aspx%3Fcid%3D58b872a7ef66745e%26amp%3Bpage%3Dview%26amp%3Bresid%3D58B872A7EF66745E!113%26amp%3BparId%3D58B872A7EF66745E!101%26amp%3Bapp%3DExcel%3C%2FA%3E%3C%2FP%3E%3CP%3EThank%20You%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1766457%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20combinations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1766457%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F826237%22%20target%3D%22_blank%22%3E%40kobus1305%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20opened%20the%20file%20from%20the%20link%20in%20the%20post%20and%20it%20is%20there.%3C%2FP%3E%3CP%3EHope%20with%20all%20of%20my%20heart%20you%20find%20it!!!%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EThank%20You%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hi, I have a workbook with two worksheets. First worksheet called Prices, master list of products and prices that changes any time. Second sheet called January contains quotes, purchase orders, purchase requests or invoices. In January worksheet there is drop down lists each row its own list under Product Description column. Next to Product Description is Price column for each selected product. Price cell i use vlookup to retrieve the price of the selected product which works fine. But now when the price of a product in Prices worksheet is changed all the products in history business of all that products changes!!! How can i resolve that problem that once a product in a cell has been selected and the price retrieved that that price never changes ever??????

Regards

Thank You

22 Replies
Highlighted

@kobus1305 

Afraid that doesn't work such way, Excel doesn't keep the history. As variant you may complicate the logic a bit keeping not only the price for the product, but also dates when the new price was assigned. With that you may check in which date range the invoice is and pick-up the proper price based both on product and date.

Highlighted

@kobus1305 

 Once VLookup formula returns a price for any product, if  you copy the formula cell and paste it back as a Values, that price cell is no longer connected to the first worksheet so any change in price will not affect it. Doing this manually would be a cumbersome task so instead of using VLookup, you may use VBA to get the price of a product from the first worksheet as a value only, that would resolve your issue.

You may consider a Change Event code on second worksheet so that once you select a Product from the drop down in the product column, the corresponding price column is automatically populated with the selected product's price and you will end up having no formula in the price column. Sounds good?

Highlighted

@Subodh_Tiwari_sktneer 

Thank you so much sounds like a problem solver. Can i pick your brain some more i am not so fimiliar with exactly what Change Event code consists of and the implementation thereof.

Regards

Highlighted

@Sergei Baklan Thank you for your response. Actual fact i only want to keep the price on the January worksheet for each selected product price either quotes, purchase orders, purchase requests or invoices static the date of each business is linked from another workbook like Date, Validity date, Company, Responsible person, Company Address, Cell Phone and Responsible Person Completing the form.

Regards

Thank You 

Highlighted

@kobus1305 

VBA solution would be specific to the layout of your data on both the sheets.

If you share your file, I can build a solution for you.

If your file contains private data, save your file to either One Drive or Google Drive and share the link with me in a private message.

 

OR share a sample file after removing any confidential data which has the layout as same as of your original file, I will build the solution in the sample file and let you know how you can implement the solution in your original file and how to tweak the code if required.

Highlighted

@Subodh_Tiwari_sktneer 

I would be so thankfull no private info just data referring to no one

https://onedrive.live.com/edit.aspx?cid=58b872a7ef66745e&page=view&resid=58B872A7EF66745E!110&parId=....

Regards

Thank You

Highlighted

@kobus1305 

When I opened the link you provided, all it says is this...

"This item might not exist or is no longer available"

 

You may upload the file here itself.

Highlighted

@Subodh_Tiwari_sktneer 

I have just opened it using the same link i have send you!!!

 

Highlighted
Highlighted

@kobus1305 

I have opened the file from the link in the post and it is there.

Hope with all of my heart you find it!!!

Regards

Thank You

Highlighted

@kobus1305 

Still the same issue.

Well, let's not make it more complex and as I said you may upload the file here itself.

To do so, click the link brows below the reply window and upload the file.

Refer to the following screenshot.

Upload_File.jpg

Highlighted

@Subodh_Tiwari_sktneer 

Hi,

You must be fedup with me by know i have copied it as you suggested.

 

Thank You so much for your efforts

Regards

Highlighted

@kobus1305 

 

Sorry for the late reply as I was busy in a project.

 

Please find the attached with the Sheet Change Event code placed on ThisWorkbook Module.

 

To test the code, go to any Month Sheet and select a Product from any Product Description Column and the Unit Price will be automatically populated in the relevant cell.

 

If you change the price of an existing product on Product List Sheet, the already existing Unit Prices for that product on any month sheet will not be changed.

 

But if you wish to update the existing old prices for that item on Month Sheets for some reason, all you need to do is, delete the selected Product and the corresponding Old Price would also be deleted and if you select the Product again from the drop down. the new price would be reflected in the corresponding Unit Price column.

 

Please let me know if that works as desired on your end.

 

 

Highlighted

Forgot to post the code I have placed on ThisWorkbook Module.

 

Code:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
Dim r As Long
Dim c As Long

r = Target.Row
c = Target.Column
On Error GoTo Skip
If VBA.Trim(LCase(Sh.Cells(2, c).Value)) = "product description" Then
    If Target <> "" Then
        If Target.Offset(0, -2) = "" Then
            Application.EnableEvents = False
            With Target.Offset(0, -2)
                .FormulaR1C1 = "=IF(OR(RC[2]="""",RC[2]=""None""),0,VLOOKUP(RC[2],'Product List'!R3C1:R20C3,3,FALSE))"
                .Value = .Value
            End With
        End If
    Else
        Target.Offset(0, -2) = ""
    End If
End If

Skip:
Application.EnableEvents = True
End Sub
Highlighted

@Subodh_Tiwari_sktneer 

Hi, yes thank you for the code. Just a question what do i need to do to get it to work?

Regards

Thank You

Highlighted

@kobus1305 

When you download and open the file I uploaded, it would be opened in Protected View and you will need to click on Enable Editing when prompted.

 

Haven't you tested it yet?

Highlighted

@Subodh_Tiwari_sktneer 

Hi, Yes i have disabled protected view and enabled macros but if i click on a product description cell the price do not change. Sorry for being a nuisance to you i have used Visual Studio 6 extensively developed large management systems for two companies but never used VBA for Excel before so i do not know how the two, Excel and VBA, fits together and what to do.

Thank You so much!!!!

Regards 

Highlighted
Best Response confirmed by kobus1305 (Contributor)
Solution

@kobus1305 

Don't worry, I know that you are dealing with Macros very first time. But once you get the idea about how they work and what they can do for you, you will start learning them.

 

Please watch this short demo video (with no audio) to know how this works.

Let me know if doing the same on your end doesn't work for you.

 

Highlighted
Hi,
Guest what i found what was wrong and thank you so so so much appreciate all your evert to help me. All the regards to you!!!!!
Thank You