excel - VBA, copy and paste lots of rows in another worksheet with a criteria -


OK, I'm a newbie in VBA so I'm seeking some help. So I have a file with an experiment with lots of data basically, I have 21 steps of measurement and N points are entered for each stage. Each stage is on a worksheet and I can search them with the word "step" for each step I want to copy the N points and send it to another sheet, I wrote a macro but to create a new sheet Nothing has happened except for nothing. You can take a look at the code given below:

sub-mymacro () worksheet (" Laos "). Active dim n long dim as I dim byte dim LastRow Long Dim WS worksheet set as WS as as = Sheets. Add Worksheets ("Laos") with LastRow =. Calls (.Ray. Counts, "A"). End (XLEEP). RO end for N = 1 with last row with worksheets ("Laos") If (n, 1) = "step" for that then i = 1 to 9763 'n digits have been recorded. Rove (i) .copy destination: = ws range ("a" and. / Code> <

You should do this if I send your original post I'm trying to do this, which I probably did not have. More information about the layout of your sheet will help. This concept is probably enough, although you have to teach it what you want. See the given screenshots to understand.

In this example, you have already created the target sheet. You just need to create header rows, and to name the sheet, then when you declare variable newSheet = In this example, declare counter as "whatever you name that sheet", this "TargetSheet"

  sub mymacro () 'integer, dim oRow not dim the integer dim as I dim the integer LastRow integer dim LastNewRow integer dim as newSheet string dim Nrow String dim n integer dim LastNCol integer dim as searchString string as in the form of as' AS 'as not sure how value N is the value of the string as the dim value' Sheets ('Laos' "If you do not need to create a new worksheet every time, just declare it. Set NewSheet = "TargetSheet" to 'LastRow' by setting it on a sheet and range basis. LastRow = Sheet ("Laos"). Range ("A65536") End (xlUp) .Row LastNewRow = Sheet (newSheet) .Range ("A65536"). End line set new. Sheet Nrow = 2 'oRow = Original Line at End. (XlUp). For the last row of oRow = 2, this line # N:, value = "InStr (InString) function gives a value for column A for" root "in the text, then the meaning is greater than 0 meaning" step "Search String = Sheets (" Laos "). Cell (Oro, 1) If INSAT (SearchString, "Step") & gt; 0 So suppose you should loop through N points, find the last column of the step line. LastNCol = Sheet ("Laos"). Cells (oRow, Columns.Count) .end (xlToLeft) .Column 'label new row sheet (newSheet) .Cells (Nrow, 1) "= Sheet (Laos"). Copy the value from the original sheet to the Seals (ORO, 1) '2 for the STA column with the RT loop n = 2' for the LastNCol, and set a new sheet along with value = sheets ("Laos"). Room (ORO, N) Sheets (New Sheet). Game (NRO, N) = Value Next N 'Since we are copying all the N points in new line, we increase NRO + 1 nRow = nRow + 1' end Should the next ORO and sub  

Laos sheet target sheet


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -