как циклично выполниться через столбцы строк в Excel VBA Macro

public static byte[] getBytesFromInputStream(InputStream is) throws IOException {
    ByteArrayOutputStream os = new ByteArrayOutputStream(); 
    byte[] buffer = new byte[0xFFFF];
    for (int len = is.read(buffer); len != -1; len = is.read(buffer)) { 
        os.write(buffer, 0, len);
    }
    return os.toByteArray();
}
9
задан Glorfindel 29 March 2019 в 09:00
поделиться

3 ответа

Вот мой совет:

Dim i As integer, j as integer

With Worksheets("TimeOut")
    i = 26
    Do Until .Cells(8, i).Value = ""
        For j = 9 to 100 ' I do not know how many rows you will need it.'
            .Cells(j, i).Formula = "YourVolFormulaHere"
            .Cells(j, i + 1).Formula = "YourCapFormulaHere"
        Next j

        i = i + 2
    Loop
 End With
6
ответ дан 4 December 2019 в 22:29
поделиться

Try this:

Create A Macro with the following thing inside:

Selection.Copy
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 1).Select
Selection.Copy
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(0, -1).Select

That particular macro will copy the current cell (place your cursor in the VOL cell you wish to copy) down one row and then copy the CAP cell also.

This is only a single loop so you can automate copying VOL and CAP of where your current active cell (where your cursor is) to down 1 row.

Just put it inside a For loop statement to do it x number of times. like:

For i = 1 to 100 'Do this 100 times
    Selection.Copy
    ActiveCell.Offset(1, 0).Select
    ActiveSheet.Paste
    ActiveCell.Offset(-1, 1).Select
    Selection.Copy
    ActiveCell.Offset(1, 0).Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, -1).Select
Next i
1
ответ дан 4 December 2019 в 22:29
поделиться

Я бы рекомендовал метод AutoFill объекта Range для этого:

rngSource.AutoFill Destination:=rngDest

Укажите диапазон источника, который содержит значения или формулы, которые вы хотите заполнить, а Целевой диапазон - как весь диапазон, которым вы хотите заполнить ячейки. Диапазон назначения должен включать диапазон источника. Вы можете заполнить как поперек, так и вниз.

Это работает точно так же, как если бы вы вручную «перетаскивали» ячейки в углу с помощью мыши; абсолютные и относительные формулы работают должным образом.

Вот пример:

'Set some example values'
Range("A1").Value = "1"
Range("B1").Formula = "=NOW()"
Range("C1").Formula = "=B1+A1"

'AutoFill the values / formulas to row 20'
Range("A1:C1").AutoFill Destination:=Range("A1:C20")

Надеюсь, это поможет.

0
ответ дан 4 December 2019 в 22:29
поделиться
Другие вопросы по тегам:

Похожие вопросы: