ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Starting with A2! (https://www.excelbanter.com/excel-programming/326812-starting-a2.html)

Alen32

Starting with A2!
 
This code insert values in column a,b and d. I would like to start with
cell A2 instead of A1. Please help.

With wbDest.Sheets("Ark1")

For i = LBound(a) To UBound(a)
.Cells(i, "a") = a(i, 1): .Cells(i, "b") = a(i, 2): .Cells(i,
"d") = a(i, 3)
Next


End With


Robert Bruce[_2_]

Starting with A2!
 
Alen32 wrote:
This code insert values in column a,b and d. I would like to start
with cell A2 instead of A1. Please help.

With wbDest.Sheets("Ark1")

For i = LBound(a) To UBound(a)
.Cells(i, "a") = a(i, 1): .Cells(i, "b") = a(i, 2):
.Cells(i, "d") = a(i, 3)
Next


End With


I think this should work:

dim i As Long, j As Long, k As Long, l As Long
const ROW_START as long = 2

With wbdest.Sheets("Ark1")

j = LBound(a, 1)
k = UBound(a, 1)
l = ROW_START - j
For i = j To k
.Cells(i + l, "a") = a(i, 1)
.Cells(i + l, "b") = a(i, 2)
.Cells(i + l, "d") = a(i, 3)
Next


End With

HTH

Rob



Alen32

Starting with A2!
 
With your code inserting start with cell A10


Alen32

Starting with A2!
 
It works very well
When I copy from here some number one change to l I don't know why.



All times are GMT +1. The time now is 09:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com