excel vba - How can I paste the value from one sheet to another using macro/vba? -


In sheet 1, I have various items that I need to populate with the given ID in the sheet. Example below:

Sheet1:

  column1 column2 -------------- - No data bag for boots data jacket no data   

sheet 2:

  column 1 ---- --- I want to search for advice from a specialist if possible, or if I call "Sheet1 Column 2" - KL-123 BC-223 AK-477 AB-987 In "Sheet 2 column 1", I can get a macro to fill below the values. Sheet 1 multiplies on the basis of number of items in "Sheet 2".  

Sheet 1

  Column 1 Column 2 ---------- -------- Shoe KL -123 KL-123 jacket KL-123 Shoe BC-223 bag BC 223 jacket BC-223 Shoe AK-477 bag AK-477 jacket AK 477 Shoe AB-987 bag AB-987 jacket AB-987    

Try it out:

  option clear 'option base 1 is not really necessary My assumptions are correct   
  sub-testing () dim sh1 worksheet, dim myIDs dim as sh2 worksheet ItmRng as range Dim I as Long Set sh1 = Thisworkbook.Sheets ("Sheet1") set sh2 = Thisworkbook.Sheets ("Sheet2") sh2 '~~ & gt; with. Get your items' ~ ~ & gt; Basically, the values ​​of the category below are given for an array of myIDs = Application.Transpose (. ("A1", _Range ("A" and "rows.Count.") End (xlUp) .address)) ending with Sh1 ' ~~> Get your object chain to set itmRng =. Range ("A1", ranges ("A" and "Roe" count). End (XLEP). Editors) '~~ & gt; Populate columns for i = UID (myIDs) for 'myIDs'' ~~ & gt; The recurrence of array values ​​also determines how many '~ ~ & gt; Many times you need to copy your item range to itmRng. Copy itmRng.Offset ((i-1) * itmRng.Rows.Count, 0) itmRng.Offset ((i-1) * itmRng.Rows.Count, 1) = myIDs I) Next End with End Closing   

Editing 1: Already tested, hopefully this helps you a little.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -