Updating Prices from a master list through the workbook VBA2019 Community Moderator ElectionWhat is the easiest way to take two columns of data and convert to dictionary?Excel VBA to determine last non-value (IE may have a formula but no value) row in columnVBA code for updating master workbook with data in raw fileVBA Comparative List Return Updated ValuesConditional copy Excel File-2 data to excel file-1?Copy value to multiple worksheetsAuto update data from live sheet 1 to sheet 2,sheet3 in every 5 minuteTake the date in one worksheet and find the same date in another worksheet column and return the cell reference for that date to use in a loopCopy non-adjacent cells and paste transpose but not to an entire rowexcel VBA code to ignore an email attachment if missing from folderVBA Code to Check one Column Data with Multiple Columns Data?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

Who is flying the vertibirds?

Is there a data structure that only stores hash codes and not the actual objects?

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

How to read the value of this capacitor?

My adviser wants to be the first author

Life insurance that covers only simultaneous/dual deaths

How to create the Curved texte?

Is it possible to upcast ritual spells?

Does Mathematica reuse previous computations?

how to write formula in word in latex

Why is the President allowed to veto a cancellation of emergency powers?

Why would a flight no longer considered airworthy be redirected like this?

Why doesn't the EU now just force the UK to choose between referendum and no-deal?

Time travel from stationary position?

Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?

Are there other languages, besides English, where the indefinite (or definite) article varies based on sound?

Did Ender ever learn that he killed Stilson and/or Bonzo?

How do anti-virus programs start at Windows boot?

How to use deus ex machina safely?

What's the meaning of “spike” in the context of “adrenaline spike”?

How to terminate ping <dest> &

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

How to deal with taxi scam when on vacation?



Updating Prices from a master list through the workbook VBA



2019 Community Moderator ElectionWhat is the easiest way to take two columns of data and convert to dictionary?Excel VBA to determine last non-value (IE may have a formula but no value) row in columnVBA code for updating master workbook with data in raw fileVBA Comparative List Return Updated ValuesConditional copy Excel File-2 data to excel file-1?Copy value to multiple worksheetsAuto update data from live sheet 1 to sheet 2,sheet3 in every 5 minuteTake the date in one worksheet and find the same date in another worksheet column and return the cell reference for that date to use in a loopCopy non-adjacent cells and paste transpose but not to an entire rowexcel VBA code to ignore an email attachment if missing from folderVBA Code to Check one Column Data with Multiple Columns Data?










0















I have a master price worksheet (Test Price) with product name (col A) and price (col B). I want to create a macro that when you click a button it will update the prices through the entire workbook. The previous person in my position already created a MOD that will update prices throughout the WB if it is changed in one WS. I am trying to link the master list to that code. So loop through the list and update one sheet which will use the existing mod to update all other sheets. Can anyone please help with this?



This is the code that updates the sheets, I need to link the master price list to this:



Sub ChangePrice(row As String, price As String)

Dim cropVal As String: cropVal = Cells(row, 2).Value ' inefficient
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price

End If


Next i


End If
Next ws

End Sub









share|improve this question
























  • Please provide the code you have so far along with any errors you are encountering.

    – Zack E
    Mar 6 at 20:05











  • I need to know how to loop through the list of values, grab the price and put it in another worksheet with the corresponding product name. I have a snippet of code already that will then update every other sheet. I just don't know how to get prices from the master price list to the first sheet

    – vchughes
    Mar 6 at 20:11











  • On this line If ws.Cells(3, 1).Value = "Division:" Then are you looking for an actual error like #DIV?

    – Zack E
    Mar 6 at 20:22











  • No that is just to verify the worksheet. All WS that would need to be updated have "Division" in cell A3.

    – vchughes
    Mar 6 at 20:34















0















I have a master price worksheet (Test Price) with product name (col A) and price (col B). I want to create a macro that when you click a button it will update the prices through the entire workbook. The previous person in my position already created a MOD that will update prices throughout the WB if it is changed in one WS. I am trying to link the master list to that code. So loop through the list and update one sheet which will use the existing mod to update all other sheets. Can anyone please help with this?



This is the code that updates the sheets, I need to link the master price list to this:



Sub ChangePrice(row As String, price As String)

Dim cropVal As String: cropVal = Cells(row, 2).Value ' inefficient
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price

End If


Next i


End If
Next ws

End Sub









share|improve this question
























  • Please provide the code you have so far along with any errors you are encountering.

    – Zack E
    Mar 6 at 20:05











  • I need to know how to loop through the list of values, grab the price and put it in another worksheet with the corresponding product name. I have a snippet of code already that will then update every other sheet. I just don't know how to get prices from the master price list to the first sheet

    – vchughes
    Mar 6 at 20:11











  • On this line If ws.Cells(3, 1).Value = "Division:" Then are you looking for an actual error like #DIV?

    – Zack E
    Mar 6 at 20:22











  • No that is just to verify the worksheet. All WS that would need to be updated have "Division" in cell A3.

    – vchughes
    Mar 6 at 20:34













0












0








0








I have a master price worksheet (Test Price) with product name (col A) and price (col B). I want to create a macro that when you click a button it will update the prices through the entire workbook. The previous person in my position already created a MOD that will update prices throughout the WB if it is changed in one WS. I am trying to link the master list to that code. So loop through the list and update one sheet which will use the existing mod to update all other sheets. Can anyone please help with this?



This is the code that updates the sheets, I need to link the master price list to this:



Sub ChangePrice(row As String, price As String)

Dim cropVal As String: cropVal = Cells(row, 2).Value ' inefficient
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price

End If


Next i


End If
Next ws

End Sub









share|improve this question
















I have a master price worksheet (Test Price) with product name (col A) and price (col B). I want to create a macro that when you click a button it will update the prices through the entire workbook. The previous person in my position already created a MOD that will update prices throughout the WB if it is changed in one WS. I am trying to link the master list to that code. So loop through the list and update one sheet which will use the existing mod to update all other sheets. Can anyone please help with this?



This is the code that updates the sheets, I need to link the master price list to this:



Sub ChangePrice(row As String, price As String)

Dim cropVal As String: cropVal = Cells(row, 2).Value ' inefficient
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price

End If


Next i


End If
Next ws

End Sub






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 7:58









Pᴇʜ

23.9k62952




23.9k62952










asked Mar 6 at 19:54









vchughesvchughes

61




61












  • Please provide the code you have so far along with any errors you are encountering.

    – Zack E
    Mar 6 at 20:05











  • I need to know how to loop through the list of values, grab the price and put it in another worksheet with the corresponding product name. I have a snippet of code already that will then update every other sheet. I just don't know how to get prices from the master price list to the first sheet

    – vchughes
    Mar 6 at 20:11











  • On this line If ws.Cells(3, 1).Value = "Division:" Then are you looking for an actual error like #DIV?

    – Zack E
    Mar 6 at 20:22











  • No that is just to verify the worksheet. All WS that would need to be updated have "Division" in cell A3.

    – vchughes
    Mar 6 at 20:34

















  • Please provide the code you have so far along with any errors you are encountering.

    – Zack E
    Mar 6 at 20:05











  • I need to know how to loop through the list of values, grab the price and put it in another worksheet with the corresponding product name. I have a snippet of code already that will then update every other sheet. I just don't know how to get prices from the master price list to the first sheet

    – vchughes
    Mar 6 at 20:11











  • On this line If ws.Cells(3, 1).Value = "Division:" Then are you looking for an actual error like #DIV?

    – Zack E
    Mar 6 at 20:22











  • No that is just to verify the worksheet. All WS that would need to be updated have "Division" in cell A3.

    – vchughes
    Mar 6 at 20:34
















Please provide the code you have so far along with any errors you are encountering.

– Zack E
Mar 6 at 20:05





Please provide the code you have so far along with any errors you are encountering.

– Zack E
Mar 6 at 20:05













I need to know how to loop through the list of values, grab the price and put it in another worksheet with the corresponding product name. I have a snippet of code already that will then update every other sheet. I just don't know how to get prices from the master price list to the first sheet

– vchughes
Mar 6 at 20:11





I need to know how to loop through the list of values, grab the price and put it in another worksheet with the corresponding product name. I have a snippet of code already that will then update every other sheet. I just don't know how to get prices from the master price list to the first sheet

– vchughes
Mar 6 at 20:11













On this line If ws.Cells(3, 1).Value = "Division:" Then are you looking for an actual error like #DIV?

– Zack E
Mar 6 at 20:22





On this line If ws.Cells(3, 1).Value = "Division:" Then are you looking for an actual error like #DIV?

– Zack E
Mar 6 at 20:22













No that is just to verify the worksheet. All WS that would need to be updated have "Division" in cell A3.

– vchughes
Mar 6 at 20:34





No that is just to verify the worksheet. All WS that would need to be updated have "Division" in cell A3.

– vchughes
Mar 6 at 20:34












1 Answer
1






active

oldest

votes


















0














You could create a dictionary of the values and then pass the dictionary to the module. You would need to add a For Each loop to your master sheet to find the row with the product for each specific worksheet.



Sub CropValFind()
Dim ProdCol As Range, Cell As Range, PriceCol As Range
Set ProdCol = 'Your product column range here
Set PriceCol = 'Your Price Column range here
For Each Cell in ProdCol
Call ChangePrice(Cell.Value, CreateDictFromColumns("MasterSheetName", ProdCol.Column, PriceCol.Column))
Next
End Sub


Assuming your product and price columns are adjacent to each other and the values are strings:



Pulled from https://stackoverflow.com/a/33523909/10462532



Function CreateDictFromColumns(sheet As String, keyCol As String, valCol As String) As Dictionary
Set CreateDictFromColumns = New Dictionary
Dim rng As Range: Set rng = Sheets(sheet).Range(keyCol & ":" & valCol)
Dim i As Long
Dim lastCol As Long '// for non-adjacent ("A:ZZ")
lastCol = rng.Columns.Count
For i = 1 To rng.Rows.Count
If (rng(i, 1).Value = "") Then Exit Function
CreateDictFromColumns.Add rng(i, 1).Value, rng(i, lastCol).Value
Next
End Function


Then your ChangePrice Sub would look something like this.



Sub ChangePrice(row As String, price As Dictionary)
Dim cropVal As String: cropVal = row
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price(row)

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price(row)

End If


Next i


End If
Next ws
End Sub


A great resource to learn the in's and outs of dictionaries can be found here.






share|improve this answer

























  • I updated with MOD code. Prices(B) are adjacent to the product(A) and products are in alphabetical order on the master sheet. I was thinking Loop through master list, find product, price, update existing sheet. The mod code would then take care of the rest

    – vchughes
    Mar 6 at 20:36












  • I saw. Edited my answer to include your added code.

    – Steve Joppich
    Mar 6 at 20:48










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031201%2fupdating-prices-from-a-master-list-through-the-workbook-vba%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You could create a dictionary of the values and then pass the dictionary to the module. You would need to add a For Each loop to your master sheet to find the row with the product for each specific worksheet.



Sub CropValFind()
Dim ProdCol As Range, Cell As Range, PriceCol As Range
Set ProdCol = 'Your product column range here
Set PriceCol = 'Your Price Column range here
For Each Cell in ProdCol
Call ChangePrice(Cell.Value, CreateDictFromColumns("MasterSheetName", ProdCol.Column, PriceCol.Column))
Next
End Sub


Assuming your product and price columns are adjacent to each other and the values are strings:



Pulled from https://stackoverflow.com/a/33523909/10462532



Function CreateDictFromColumns(sheet As String, keyCol As String, valCol As String) As Dictionary
Set CreateDictFromColumns = New Dictionary
Dim rng As Range: Set rng = Sheets(sheet).Range(keyCol & ":" & valCol)
Dim i As Long
Dim lastCol As Long '// for non-adjacent ("A:ZZ")
lastCol = rng.Columns.Count
For i = 1 To rng.Rows.Count
If (rng(i, 1).Value = "") Then Exit Function
CreateDictFromColumns.Add rng(i, 1).Value, rng(i, lastCol).Value
Next
End Function


Then your ChangePrice Sub would look something like this.



Sub ChangePrice(row As String, price As Dictionary)
Dim cropVal As String: cropVal = row
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price(row)

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price(row)

End If


Next i


End If
Next ws
End Sub


A great resource to learn the in's and outs of dictionaries can be found here.






share|improve this answer

























  • I updated with MOD code. Prices(B) are adjacent to the product(A) and products are in alphabetical order on the master sheet. I was thinking Loop through master list, find product, price, update existing sheet. The mod code would then take care of the rest

    – vchughes
    Mar 6 at 20:36












  • I saw. Edited my answer to include your added code.

    – Steve Joppich
    Mar 6 at 20:48















0














You could create a dictionary of the values and then pass the dictionary to the module. You would need to add a For Each loop to your master sheet to find the row with the product for each specific worksheet.



Sub CropValFind()
Dim ProdCol As Range, Cell As Range, PriceCol As Range
Set ProdCol = 'Your product column range here
Set PriceCol = 'Your Price Column range here
For Each Cell in ProdCol
Call ChangePrice(Cell.Value, CreateDictFromColumns("MasterSheetName", ProdCol.Column, PriceCol.Column))
Next
End Sub


Assuming your product and price columns are adjacent to each other and the values are strings:



Pulled from https://stackoverflow.com/a/33523909/10462532



Function CreateDictFromColumns(sheet As String, keyCol As String, valCol As String) As Dictionary
Set CreateDictFromColumns = New Dictionary
Dim rng As Range: Set rng = Sheets(sheet).Range(keyCol & ":" & valCol)
Dim i As Long
Dim lastCol As Long '// for non-adjacent ("A:ZZ")
lastCol = rng.Columns.Count
For i = 1 To rng.Rows.Count
If (rng(i, 1).Value = "") Then Exit Function
CreateDictFromColumns.Add rng(i, 1).Value, rng(i, lastCol).Value
Next
End Function


Then your ChangePrice Sub would look something like this.



Sub ChangePrice(row As String, price As Dictionary)
Dim cropVal As String: cropVal = row
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price(row)

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price(row)

End If


Next i


End If
Next ws
End Sub


A great resource to learn the in's and outs of dictionaries can be found here.






share|improve this answer

























  • I updated with MOD code. Prices(B) are adjacent to the product(A) and products are in alphabetical order on the master sheet. I was thinking Loop through master list, find product, price, update existing sheet. The mod code would then take care of the rest

    – vchughes
    Mar 6 at 20:36












  • I saw. Edited my answer to include your added code.

    – Steve Joppich
    Mar 6 at 20:48













0












0








0







You could create a dictionary of the values and then pass the dictionary to the module. You would need to add a For Each loop to your master sheet to find the row with the product for each specific worksheet.



Sub CropValFind()
Dim ProdCol As Range, Cell As Range, PriceCol As Range
Set ProdCol = 'Your product column range here
Set PriceCol = 'Your Price Column range here
For Each Cell in ProdCol
Call ChangePrice(Cell.Value, CreateDictFromColumns("MasterSheetName", ProdCol.Column, PriceCol.Column))
Next
End Sub


Assuming your product and price columns are adjacent to each other and the values are strings:



Pulled from https://stackoverflow.com/a/33523909/10462532



Function CreateDictFromColumns(sheet As String, keyCol As String, valCol As String) As Dictionary
Set CreateDictFromColumns = New Dictionary
Dim rng As Range: Set rng = Sheets(sheet).Range(keyCol & ":" & valCol)
Dim i As Long
Dim lastCol As Long '// for non-adjacent ("A:ZZ")
lastCol = rng.Columns.Count
For i = 1 To rng.Rows.Count
If (rng(i, 1).Value = "") Then Exit Function
CreateDictFromColumns.Add rng(i, 1).Value, rng(i, lastCol).Value
Next
End Function


Then your ChangePrice Sub would look something like this.



Sub ChangePrice(row As String, price As Dictionary)
Dim cropVal As String: cropVal = row
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price(row)

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price(row)

End If


Next i


End If
Next ws
End Sub


A great resource to learn the in's and outs of dictionaries can be found here.






share|improve this answer















You could create a dictionary of the values and then pass the dictionary to the module. You would need to add a For Each loop to your master sheet to find the row with the product for each specific worksheet.



Sub CropValFind()
Dim ProdCol As Range, Cell As Range, PriceCol As Range
Set ProdCol = 'Your product column range here
Set PriceCol = 'Your Price Column range here
For Each Cell in ProdCol
Call ChangePrice(Cell.Value, CreateDictFromColumns("MasterSheetName", ProdCol.Column, PriceCol.Column))
Next
End Sub


Assuming your product and price columns are adjacent to each other and the values are strings:



Pulled from https://stackoverflow.com/a/33523909/10462532



Function CreateDictFromColumns(sheet As String, keyCol As String, valCol As String) As Dictionary
Set CreateDictFromColumns = New Dictionary
Dim rng As Range: Set rng = Sheets(sheet).Range(keyCol & ":" & valCol)
Dim i As Long
Dim lastCol As Long '// for non-adjacent ("A:ZZ")
lastCol = rng.Columns.Count
For i = 1 To rng.Rows.Count
If (rng(i, 1).Value = "") Then Exit Function
CreateDictFromColumns.Add rng(i, 1).Value, rng(i, lastCol).Value
Next
End Function


Then your ChangePrice Sub would look something like this.



Sub ChangePrice(row As String, price As Dictionary)
Dim cropVal As String: cropVal = row
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets

'simple check for division in A3 (stronger check may be needed)
If ws.Cells(3, 1).Value = "Division:" Then

LastRow = ws.Range("A" & Rows.count).End(xlUp).row

' starts in row 12, though data starts in 13
For i = 12 To LastRow

'check column 2 if crop is the same
If ws.Cells(i, 2).Value = cropVal Then

'if so, change its price in column 10
ws.Cells(i, 10).Value = price(row)

'this handles situations where the symbol is attached
ElseIf ws.Cells(i, 2).Value = cropVal & "®" Then

ws.Cells(i, 10).Value = price(row)

End If


Next i


End If
Next ws
End Sub


A great resource to learn the in's and outs of dictionaries can be found here.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 6 at 21:29

























answered Mar 6 at 20:18









Steve JoppichSteve Joppich

446




446












  • I updated with MOD code. Prices(B) are adjacent to the product(A) and products are in alphabetical order on the master sheet. I was thinking Loop through master list, find product, price, update existing sheet. The mod code would then take care of the rest

    – vchughes
    Mar 6 at 20:36












  • I saw. Edited my answer to include your added code.

    – Steve Joppich
    Mar 6 at 20:48

















  • I updated with MOD code. Prices(B) are adjacent to the product(A) and products are in alphabetical order on the master sheet. I was thinking Loop through master list, find product, price, update existing sheet. The mod code would then take care of the rest

    – vchughes
    Mar 6 at 20:36












  • I saw. Edited my answer to include your added code.

    – Steve Joppich
    Mar 6 at 20:48
















I updated with MOD code. Prices(B) are adjacent to the product(A) and products are in alphabetical order on the master sheet. I was thinking Loop through master list, find product, price, update existing sheet. The mod code would then take care of the rest

– vchughes
Mar 6 at 20:36






I updated with MOD code. Prices(B) are adjacent to the product(A) and products are in alphabetical order on the master sheet. I was thinking Loop through master list, find product, price, update existing sheet. The mod code would then take care of the rest

– vchughes
Mar 6 at 20:36














I saw. Edited my answer to include your added code.

– Steve Joppich
Mar 6 at 20:48





I saw. Edited my answer to include your added code.

– Steve Joppich
Mar 6 at 20:48



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031201%2fupdating-prices-from-a-master-list-through-the-workbook-vba%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко