Wednesday, 15 June 2011

excel - how to copy text from column of active sheet and past it to another sheet according to the specific row and column number which are in active sheet -


I am new to excel vba. I want to write a macro which can copy the text value from column A to the last line from the first line and back it on another sheet of the same wordbook, but the complex part is that I have this text specific Line and column number that are given in the active sheet in column B and C.

This is an example of my data in active sheet:

  column One way Column B. Column C text value row column aaaa 1 1aaa 1 2 bbbb 1 3bbbb 1 4 cccc 1 cccc 1 6 dddd 2 1 dddd 2 2 dddd 2 3 eeee 2 4 eeee 2 5 fff 2 6  

and so on.

The result sheet should be:

  column A column B column C column D column E column F ..... 1 aaaa BBBB BBBB CCCC CCCC 2DDDD DDDD DDD EEFFFF3 4  

This should work for you.

  option clear sub copy_rng () as a working book, as ws1 worksheet, ws1 as the worksheet dim in the form of slow lane, as long as dim myArray () As the version set wb = ThisWorkbook set ws1 = wb.Sheets ("Sheet1") set ws2 = wb sheets ("Sheet2") Lowe = cells (rows.account, 1). End (XLEEP). Ro Mayer () = ws1. Range (cells (1, 1), cells (LLO, 3)). Price Version 2 Activate I = 1 for Ubound (myArray) cell (myArray (i, 2), myArray (i, 3)) Value2 = myArray (i, 1) if myArray (i, 4) = 1 then cells (myArray , 2), my array (i, 3). Internal. My color = xl theme caller accent 1 'blue alsieriarrierre (mine, 4) = 2 then cells (Marraye (I, 2), IARRA (I, 3)). Internal.IMFCLLR = XLThemeExenta2 'Red ALSIF MyAre (I, 4) = 3 then cells (MyEre (I, 2), IARRA (I, 3)) .IEEELER = XLThemeExchange 3' green Lei If Irene (I, 4) = 4 then cells (Mariere (I, 2), Mayor (I, 3)) Internal.IMELL = XLThemeClickerExchange 6 'Orange Closing If Next I End Substitutes  

You can create an array with data from worksheet 1, and then use the column number from row to copy data from column A to right ales.


No comments:

Post a Comment