Hi all,
I have sheet("data_new") and want to copy data to another sheet with conditions that:
Please help me to do that with VBA code, i try hard but there's mistake with my codePlease Login or Register to view this content.
Hi all,
I have sheet("data_new") and want to copy data to another sheet with conditions that:
Please help me to do that with VBA code, i try hard but there's mistake with my codePlease Login or Register to view this content.
Last edited by sbv1986; 03-28-2019 at 08:22 PM.
See how this works for you.
Please Login or Register to view this content.
Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
Just when I think I am smart, I learn something new!
Thanks @JLGWhiz but code yellow in line If .Cells(i, "M").Value + .Cells(i, "N").Value < .Cells(i, j).Value Then
with info: Run time error 13, type mismatch
You need to edit your Data_new worksheet to eliminate
these type error displays and any other non-numeric cell values in columns M and N. They are the cause of your error message. You cannot subtract a numeric value from a non-numeric value and vba will definitely let you know it is there. You could put an 'On Error Resume Next' Statement in the code which would just step over those rows, but it is better that you clean the database so the code runs properly.#DIV/0!
The code was working fine until it hit row 100.
Pefect @JLGWhiz, I delete cell #DIV/0! anf code worked okey.
May i have final question, with each value has just found in column B of sheets (higher/lower"), I want to compare with old data in sheets("Data_Old").
How can I add value from sheets("data_old") to column(D) for each value into sheets("higher") or sheets("lower").
Many thanks./.
Administrative Note:
We would love to help you with your query; however, you need to include code tags around your code.
Please take a moment to add the tags. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.
Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
(Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
HTH
Regards, Jeff
thanks @jeffreybrown, I've just edit as you said.
Make sure columns M and N are all numeric in data_old and then try this.
Please Login or Register to view this content.
Thanks for your respond @JLGWhiz but this code don'w work that I want
With code working well on #2, I want code adding data in sheets("data_old") into sheets("higher or lower").column(D) when each cell in sheets(higher or lower).column("B") match with each cell in sheets("data_old').row(2).
Sorry I mark this thread as solved and create new onw at this: https://www.excelforum.com/excel-pro...ew-thread.html
That needs to be started as a new thread. It is a different requirement than the original post, per forum rules as you obviouly have done.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks