This macro searches for values in the "FROM NIPI EMA(20230530)" worksheet and copies corresponding values from the "FROM VELE EMA(20230530)" worksheet.

First, it declares and initializes variables for the worksheets, ranges, last rows, cells, search value, found cells, and copy value.

It then disables screen updating, calculation, and events to improve performance.

Next, it loops through each cell in the "FROM NIPI EMA(20230530)" worksheet range starting from column D.

For each cell, it retrieves the search value and searches for all matching cells in the "FROM VELE EMA(20230530)" worksheet column G.

If matching cells are found, it copies the corresponding values from column E in each matching row, separates them with commas, and removes the last comma.

Finally, it adds the copied values to column F in the "FROM NIPI EMA(20230530)" worksheet.

After the loop, it enables screen updating, calculation, and events.

Lastly, it displays a message box indicating that the search and copy process is complete.

Excel VBA Macro: Search and Copy Values from Two Worksheets

原文地址: https://www.cveoy.top/t/topic/p3hq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录