vba - Excel 2013 - How to copy data from one sheet to another based on formatting -


I have an Excel sheet with prices, and I want to automatically copy the values ​​that are highlighted (Formatted with background color) for any other sheet, I have no problem using macros or function in the second sheet cells if possible.

I have tried to keep some suggestions together and to color the cell and to filter it by following macro color value:

  sub sample () less uniform sheet As the slow stroke search string dims lRow as long set, ws = Sheets ("Sheet1") ws lRow =. ("One" & amp; .Rows.Count) End (xlUp) .ro '~~ & gt; Remove any filter. AutoFilterMode = Incorrect '~~ & gt; Set filters, offset (to exclude headers) and source space. Range ("J2: J" & amp; lRow). Autofilter Field: = 1, Criterion 1: = "6" Set Copy = .Offset (1, 0). Special Seals (XLSil Type Voicable). '~ ~ & Gt; Remove any filter. AutoFilterMode = '~~ & gt; Set the destination sheet to ws2 = Sheets ("Sheet 2") with ws2 if the application. Worksheet Function. Konta (.) And <; Lt; & Gt; 0 then lRow = .Cells.Find (what: = "*", _ followed by: =. Range ("A1"), _ luca: = xlPart, _ LookIn: = xlFormulas, _SearchOrder: = xlByRows, _SearchDirection : = Xl predecessor, _ matchys: false =). Again LRO = 1 end if copyFrom.Copy. Line end (lRow) ending with sub-function internal collar (cellar in the form of range) interior collar = cellular. Inner.color index and function   

But, in a sheet with several sheets Copy is required, and the macro states that the source sheet is continuous ... I do not want to create a macro for each separate sheet.

In addition to this, every time the macro is run, the highlighted lines will be copied that was copied before making a duplicate in the destination sheet.

I've seen a lot of posts in it about this problem but I can not find anything that is in line with my needs.

Can anyone suggest changing this code or customize a new one?

Thanks in advance!

First of all, I was nk it should be divided into two problems:

Import from different worksheets

If you want to import from different sheets, then you should write your function to accept a sheet as the parameter.

  Sub Sample (like Excel.Worksheet)   

Then you have to delete both lines Dual Worksheet Worksheet and Set = Sheets ("Sheet1") , or you will get an error or unexpected behavior.

Then you need any other work that saves all worksheets and calls your sample (worksheet) process

  Sub Sample Collar () Dim E, as Excel. Worksheet for each e in thisWorkbook Set Sheet ws = e Call Sample (ws) Next and Set ws = None End Sub   

Search the rows already present in the destination worksheet

Before you Are using only from
You can use it to find the elements already in your destination worksheet. Code> copyFrom.Copy Rows (lRow) You must use the range. To determine whether you need to copy this value.

Perhaps you should make another topic for this second issue, or use the search function.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -