vba - Copy from multiple sheets and paste into sheet 1 -


i trying data multiple worksheets , paste sheet 1 code isnt working properly. keeps copying sheet "table 1" on , on again. know wrong code?

thanks

option explicit  sub test()  dim ws worksheet dim integer      each ws in thisworkbook.worksheets         if ws.name <> "table 1"              activesheet.range("a15:x35").select             selection.copy              worksheets("table 1").activate                  = 1 5000                      if isempty(cells(i, 1)) = true , isempty(cells(i + 1, 1)) = true                     activesheet.cells(i, 1).select                     activesheet.paste                     exit                     end if                  next          end if     next ws  end sub 

inside loop, copying activesheet, not ws. if activesheet "table 1" (in fact, activate table 1 in statement worksheets("table 1").activate), of course if keep copying it.

besides, better copy directly ranges without using activate , select. guess want do:

with worksheets("table 1")     each ws in thisworkbook.worksheets         if ws.name <> "table 1"             = 1 5000                 if isempty(.cells(i, 1)) , isempty(.cells(i + 1, 1))                     ws.range("a15:x35").copy .cells(i, 1)                     exit                 end if             next         end if     next ws end 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -