Replacing Cell value in another workbook based on 2 criteria

JeremyA1976

Board Regular
Joined
Aug 3, 2015
Messages
59
Hello All,
Thanks for reading and any help I may receive..

I have a workbook that acts as a material form. I also have an Inventory workbook for all the materials we consume on a regular basis. I need help with a macro that will read from my Charge Out Template.xlsm workbook, from worksheet "LOGCOUNT". On this worksheet, down column (H), starting at row 2, there are a series of new quantities (for specific items) that I need to replace in my Inventory Sheet.xlsm, on worksheet "Inventory". On both sheets, my product description is column (A). I need the charge out form workbook to start at (H2) of sheet "LOGCOUNT" and use the cell value to find what to replace.)

For example, i have an item description "12 GA GALV 60X120" in cell (A2). In cell (G2) of the same worksheet, I have the value (D4). This is the location on the inventory workbook that I need to replace with the value of cell H2 (5). The problem is... the number of rows in column (H) can vary, so I will need it to find the last row with any text in it based on column (A), so it knows where to stop replacing values.

I am not so good with the search and find aspect of VBA and I would appreciate a clearer understanding, so I am not looking for just code, but an explanation of how it is written so I may learn.

P.S. I already use Vlookup to search and report WHERE I need to place the new value, i just need help with finding and replacing based on row.

Thanks,
Jeremy
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
The syntax to find the last row in column A is
Code:
Dim lstRw As Long
lstRw = Sheets("LOGCOUNT".Cells(Rows.Count, 1).End(xlUp).Row
lstRw would then equal the row number of the last row with data in it. The first empty row would then be lstRw + 1. You can also use Offset to designate rows or ranges in relation to the lstRow variable.
Code:
Rows(lstRw).Offset(1)
would be the next row down
Code:
Range("A" & lstRow).Offset(1)
would be the next cell down, etc.
 
Last edited:
Upvote 0
Cross posted https://www.excelforum.com/excel-pr...-in-another-workbook-based-on-2-criteria.html

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Cross posted https://www.excelforum.com/excel-pr...-in-another-workbook-based-on-2-criteria.html

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.


I apologize. I will inform the next time if I do so. I haven't had much luck with people responding to my questions on here, which is probably my fault for not explaining well enough. I didn't realize it was a rule. Thanks for informing me.
 
Upvote 0
I haven't had much luck with people responding to my questions on here
You had a reply within 1½ hours, but have not yet responded in return.
 
Upvote 0
I am trying to put together a well thought out thanks and I have more questions I am trying to figure how to ask. That remark was about previous threads and i did like the post and thanked him for sharing. I am desperately trying to learn this VBA stuff fluff
 
Upvote 0
I do appreciate your help JLG. we are almost done for the day, but I will repost a couple questions as soon as I can. Thanks for helping me understand how to find the last row. I am trying to tie it into something else and its not working and Im not sure where i am going wrong.
 
Upvote 0
I do appreciate your help JLG. we are almost done for the day, but I will repost a couple questions as soon as I can. Thanks for helping me understand how to find the last row. I am trying to tie it into something else and its not working and Im not sure where i am going wrong.
@JeremyA1976 - my suggestion would be that you do a web search for "Free VBA tutorial" and work with those (several out there) for a while. It will help you to learn basic VBA and familiarize you with the conventions used in communicating with other Excel and VBA users.
 
Upvote 0
Thank you JLG. I am doing so with your recommendation. I know I should have done this a long time ago, that is my trap. "I knew enough to be dangerous" was my mantra. now i have holes in my knowledge i can't comprehend, so the only thing to do in order to move forward is start from the beginning and understand the language. Thank you for your patience.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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